WIP: Start of creating autokick timer
All checks were successful
Test / build (push) Successful in 15s
All checks were successful
Test / build (push) Successful in 15s
This commit is contained in:
parent
9e05d884cf
commit
94a2965e8e
2 changed files with 27 additions and 1 deletions
|
@ -12,11 +12,14 @@ import ButtonEventItem from "../contracts/ButtonEventItem";
|
||||||
import { ButtonEvent } from "../type/buttonEvent";
|
import { ButtonEvent } from "../type/buttonEvent";
|
||||||
import CacheHelper from "../helpers/CacheHelper";
|
import CacheHelper from "../helpers/CacheHelper";
|
||||||
import TimerHelper from "../helpers/TimerHelper";
|
import TimerHelper from "../helpers/TimerHelper";
|
||||||
|
import AutoKick from "../timers/AutoKick";
|
||||||
|
|
||||||
export class CoreClient extends Client {
|
export class CoreClient extends Client {
|
||||||
private static _commandItems: ICommandItem[];
|
private static _commandItems: ICommandItem[];
|
||||||
private static _eventItems: IEventItem[];
|
private static _eventItems: IEventItem[];
|
||||||
private static _buttonEvents: ButtonEventItem[];
|
private static _buttonEvents: ButtonEventItem[];
|
||||||
|
private static _baseClient: Client;
|
||||||
|
|
||||||
|
|
||||||
private _events: Events;
|
private _events: Events;
|
||||||
private _util: Util;
|
private _util: Util;
|
||||||
|
@ -34,6 +37,10 @@ export class CoreClient extends Client {
|
||||||
return this._buttonEvents;
|
return this._buttonEvents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static get baseClient(): Client {
|
||||||
|
return this._baseClient;
|
||||||
|
}
|
||||||
|
|
||||||
constructor(intents: number[], partials: Partials[]) {
|
constructor(intents: number[], partials: Partials[]) {
|
||||||
super({ intents: intents, partials: partials });
|
super({ intents: intents, partials: partials });
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
@ -57,7 +64,7 @@ export class CoreClient extends Client {
|
||||||
.then(() => {
|
.then(() => {
|
||||||
console.log("Data Source Initialized");
|
console.log("Data Source Initialized");
|
||||||
|
|
||||||
// this.timerHelper.AddTimer
|
this._timerHelper.AddTimer("*/5 * * * *", "Europe/London", AutoKick, true);
|
||||||
})
|
})
|
||||||
.catch((err) => console.error("Error Initialising Data Source", err));
|
.catch((err) => console.error("Error Initialising Data Source", err));
|
||||||
|
|
||||||
|
@ -72,6 +79,8 @@ export class CoreClient extends Client {
|
||||||
|
|
||||||
this._util.loadEvents(this, CoreClient._eventItems);
|
this._util.loadEvents(this, CoreClient._eventItems);
|
||||||
this._util.loadSlashCommands(this);
|
this._util.loadSlashCommands(this);
|
||||||
|
|
||||||
|
CoreClient._baseClient = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RegisterCommand(name: string, command: Command, serverId?: string) {
|
public static RegisterCommand(name: string, command: Command, serverId?: string) {
|
||||||
|
|
17
src/timers/AutoKick.ts
Normal file
17
src/timers/AutoKick.ts
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import {CoreClient} from "../client/client";
|
||||||
|
import AutoKickConfig from "../database/entities/AutoKickConfig";
|
||||||
|
|
||||||
|
export default async function AutoKick() {
|
||||||
|
const client = CoreClient.baseClient;
|
||||||
|
const autoKickConfigs = await AutoKickConfig.FetchAll(AutoKickConfig);
|
||||||
|
|
||||||
|
for (let config of autoKickConfigs) {
|
||||||
|
const guild = client.guilds.cache.find(x => x.id == config.ServerId) || client.guilds.fetch(config.ServerId);
|
||||||
|
|
||||||
|
if (!guild) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(typeof guild);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue