mirror of
https://github.com/qwerinope/qweribot.git
synced 2025-12-20 05:51:39 +01:00
added cheers, cheer management commands, timeout cheer
This commit is contained in:
29
bot/cheers/index.ts
Normal file
29
bot/cheers/index.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { User } from '../user';
|
||||
import { EventSubChannelChatMessageEvent } from "@twurple/eventsub-base";
|
||||
|
||||
export class Cheer {
|
||||
public readonly name: string;
|
||||
public readonly amount: number;
|
||||
public readonly execute: (msg: EventSubChannelChatMessageEvent, sender: User, testmessage: boolean) => Promise<void>;
|
||||
constructor(name: string, amount: number, execution: (msg: EventSubChannelChatMessageEvent, sender: User, testmessage: boolean) => Promise<void>) {
|
||||
this.name = name.toLowerCase();
|
||||
this.amount = amount;
|
||||
this.execute = execution;
|
||||
};
|
||||
};
|
||||
|
||||
import { readdir } from 'node:fs/promises';
|
||||
const cheers = new Map<number, Cheer>;
|
||||
const namedcheers = new Map<string, Cheer>;
|
||||
|
||||
const files = await readdir(import.meta.dir);
|
||||
for (const file of files) {
|
||||
if (!file.endsWith('.ts')) continue;
|
||||
if (file === import.meta.file) continue;
|
||||
const cheer: Cheer = await import(import.meta.dir + '/' + file.slice(0, -3)).then(a => a.default);
|
||||
cheers.set(cheer.amount, cheer);
|
||||
namedcheers.set(cheer.name, cheer);
|
||||
};
|
||||
|
||||
export default cheers;
|
||||
export { namedcheers };
|
||||
Reference in New Issue
Block a user