move commands and events around

This commit is contained in:
Lio Young 2021-09-11 13:36:51 +02:00
parent c6c481f552
commit 1b43ccfda4
41 changed files with 204 additions and 301 deletions

View File

@ -1,8 +1,8 @@
import yiff from '../../utils/yiff';
import Command from '../../handler/structures/Command';
import { Context } from '../../utils/types';
import yiff from '../../../utils/yiff';
import { Command } from '@thaldrin/eu';
import { Context } from '../../../utils/types';
import { MessageEmbed } from 'discord.js';
import request from '../../utils/animals';
import request from '../../../utils/animals';
export = class Birb extends Command {
constructor() {

View File

@ -1,8 +1,8 @@
import yiff from '../../utils/yiff';
import Command from '../../handler/structures/Command';
import { Context } from '../../utils/types';
import yiff from '../../../utils/yiff';
import { Command } from '@thaldrin/eu';
import { Context } from '../../../utils/types';
import { MessageEmbed } from 'discord.js';
import request from '../../utils/animals';
import request from '../../../utils/animals';
export = class Cat extends Command {
constructor() {

View File

@ -1,8 +1,8 @@
import yiff from '../../utils/yiff';
import Command from '../../handler/structures/Command';
import { Context } from '../../utils/types';
import yiff from '../../../utils/yiff';
import { Command } from '@thaldrin/eu';
import { Context } from '../../../utils/types';
import { MessageEmbed } from 'discord.js';
import request from '../../utils/animals';
import request from '../../../utils/animals';
export = class Fox extends Command {
constructor() {

View File

@ -1,8 +1,8 @@
import yiff from '../../utils/yiff';
import Command from '../../handler/structures/Command';
import { Context } from '../../utils/types';
import yiff from '../../../utils/yiff';
import { Command } from '@thaldrin/eu';
import { Context } from '../../../utils/types';
import { MessageEmbed } from 'discord.js';
import request from '../../utils/animals';
import request from '../../../utils/animals';
export = class Hyena extends Command {
constructor() {

View File

@ -1,8 +1,8 @@
import yiff from '../../utils/yiff';
import Command from '../../handler/structures/Command';
import { Context } from '../../utils/types';
import yiff from '../../../utils/yiff';
import { Command } from '@thaldrin/eu';
import { Context } from '../../../utils/types';
import { MessageEmbed } from 'discord.js';
import request from '../../utils/animals';
import request from '../../../utils/animals';
export = class Shibe extends Command {
constructor() {

View File

@ -1,8 +1,8 @@
import yiff from '../../utils/yiff';
import Command from '../../handler/structures/Command';
import { Context } from '../../utils/types';
import yiff from '../../../utils/yiff';
import { Command } from '@thaldrin/eu';
import { Context } from '../../../utils/types';
import { MessageEmbed } from 'discord.js';
import request from '../../utils/animals';
import request from '../../../utils/animals';
export = class Wolf extends Command {
constructor() {

View File

@ -1,6 +1,6 @@
import { Context } from "../../utils/types";
import Command from "../../handler/structures/Command";
import clean from "../../utils/clean"
import { Context } from "../../../utils/types";
import { Command } from '@thaldrin/eu';
import clean from "../../../utils/clean"
export = class Eval extends Command {
constructor() {
super({

View File

@ -1,6 +1,6 @@
import Command from "../../handler/structures/Command";
import { Command } from '@thaldrin/eu';
import { exec } from "child_process";
import { Context } from "../../utils/types";
import { Context } from "../../../utils/types";
export = class Exec extends Command {
constructor() {

View File

@ -1,10 +1,10 @@
// @ts-nocheck
import Command from '../../handler/structures/Command';
import { Context } from '../../utils/types';
import { Command } from '@thaldrin/eu';
import { Context } from '../../../utils/types';
import { MessageEmbed } from 'discord.js';
import lingua from '../../utils/lingua';
import replace from '../../utils/replace';
import { request } from '../../utils/command.roleplay';
import lingua from '../../../utils/lingua';
import replace from '../../../utils/replace';
import { request } from '../../../utils/command.roleplay';
export = class Boop extends Command {
constructor() {

View File

@ -1,10 +1,10 @@
// @ts-nocheck
import Command from '../../handler/structures/Command';
import { Context } from '../../utils/types';
import { Command } from '@thaldrin/eu';
import { Context } from '../../../utils/types';
import { MessageEmbed } from 'discord.js';
import lingua from '../../utils/lingua';
import replace from '../../utils/replace';
import { request } from '../../utils/command.roleplay';
import lingua from '../../../utils/lingua';
import replace from '../../../utils/replace';
import { request } from '../../../utils/command.roleplay';
export = class Cuddle extends Command {
constructor() {

View File

@ -1,10 +1,10 @@
// @ts-nocheck
import Command from '../../handler/structures/Command';
import { Context } from '../../utils/types';
import { Command } from '@thaldrin/eu';
import { Context } from '../../../utils/types';
import { MessageEmbed } from 'discord.js';
import language from '../../utils/language';
import replace from '../../utils/replace';
import { request } from '../../utils/command.roleplay';
import language from '../../../utils/language';
import replace from '../../../utils/replace';
import { request } from '../../../utils/command.roleplay';
export = class Hold extends Command {
constructor() {

View File

@ -1,10 +1,10 @@
// @ts-nocheck
import Command from '../../handler/structures/Command';
import { Context } from '../../utils/types';
import { Command } from '@thaldrin/eu';
import { Context } from '../../../utils/types';
import { MessageEmbed } from 'discord.js';
import language from '../../utils/language';
import replace from '../../utils/replace';
import { request } from '../../utils/command.roleplay';
import language from '../../../utils/language';
import replace from '../../../utils/replace';
import { request } from '../../../utils/command.roleplay';
export = class Hug extends Command {
constructor() {

View File

@ -1,10 +1,10 @@
// @ts-nocheck
import Command from '../../handler/structures/Command';
import { Context } from '../../utils/types';
import { Command } from '@thaldrin/eu';
import { Context } from '../../../utils/types';
import { MessageEmbed } from 'discord.js';
import language from '../../utils/language';
import replace from '../../utils/replace';
import { request } from '../../utils/command.roleplay';
import language from '../../../utils/language';
import replace from '../../../utils/replace';
import { request } from '../../../utils/command.roleplay';
export = class Lick extends Command {
constructor() {

View File

@ -1,7 +1,7 @@
import { Context } from '../../utils/types';
import Command from '../../handler/structures/Command';
import { Context } from '../../../utils/types';
import { Command } from '@thaldrin/eu';
import { MessageEmbed } from 'discord.js';
import config from '../../../config';
import config from '../../../../config';
export = class Info extends Command {
constructor() {
@ -22,6 +22,7 @@ export = class Info extends Command {
})
devs = devs.join(' ')
} else {
// @ts-ignore
devs = `**[${ctx.client.users.cache.get(ctx.config.variables.developers[0].id)?.username}](${ctx.config.variables.developers[0].link})**`
}
if (ctx.config.variables.contributors.length > 1) {
@ -39,6 +40,7 @@ export = class Info extends Command {
A [Caecus](https://werewolf.design) Project\n[Consider supporting the Development of this Bot](https://lio.cat/support)`)
.addField("Contributors", `${contribs}`, false)
.addField("Source", config.variables.source, true)
// @ts-ignore
.addField("Support Server", `[${ctx.client.guilds.cache.get(ctx.config.variables.support.id)?.name}](${ctx.config.variables.support.invite})`, true)
.addField("Website", `[${ctx.config.variables.website}](https://${ctx.config.variables.website})`, true)
.setColor(ctx.config.variables.color)

View File

@ -1,11 +1,11 @@
// @ts-nocheck
import Command from '../../handler/structures/Command';
import { Context, Server } from '../../utils/types';
import database from "../../utils/database"
import { Command } from '@thaldrin/eu';
import { Context, Server } from '../../../utils/types';
import database from "../../../utils/database"
import path from 'path'
import langs from '../../utils/language';
import langs from '../../../utils/language';
import { MessageEmbed } from 'discord.js';
import replace from '../../utils/replace';
import replace from '../../../utils/replace';
import fs from 'fs'
import path from 'path'

View File

@ -1,6 +1,6 @@
import Command from '../../handler/structures/Command';
import { Context } from '../../utils/types';
import lingua from '../../utils/lingua';
import { Command } from '@thaldrin/eu';
import { Context } from '../../../utils/types';
import lingua from '../../../utils/lingua';
export = class Ping extends Command {
constructor() {
@ -14,6 +14,7 @@ export = class Ping extends Command {
async command(ctx: Context) {
const ping = await ctx.channel.send("Pinging...")
const rest = Math.round(ping.createdTimestamp - ctx.message.createdTimestamp)
// @ts-ignore
const ws = Math.round(ctx.client.ws.ping)
// @ts-ignore
const shard = Math.round(ctx.guild?.shard.ping)

View File

@ -1,9 +1,9 @@
import Command from '../../handler/structures/Command';
import { Context, Server } from '../../utils/types';
import lingua from '../../utils/lingua';
import { Command } from '@thaldrin/eu';
import { Context, Server } from '../../../utils/types';
import lingua from '../../../utils/lingua';
import { MessageEmbed } from 'discord.js';
import database from "../../utils/database"
import language from '../../utils/language';
import database from "../../../utils/database"
import language from '../../../utils/language';
function enabled(a: boolean, lang: string) {
// @ts-ignore

View File

@ -1,9 +1,9 @@
import Command from '../../handler/structures/Command';
import { Context, Usage } from '../../utils/types';
import { Command } from '@thaldrin/eu';
import { Context, Usage } from '../../../utils/types';
// import lingua from '../../utils/lingua';
import { MessageEmbed } from 'discord.js';
import CommandUsage from '../../utils/command.usage';
import { commitHash } from "../../utils/git"
// import CommandUsage from '../../../src/utils/command.usage';
import { commitHash } from "../../../utils/git"
function uptime(ms: number) {
function pad(s: number) {
@ -30,7 +30,9 @@ export = class Stats extends Command {
async command(ctx: Context) {
// @ts-ignore
const guilds = (await ctx.client.shard?.fetchClientValues(`guilds.cache.size`)).reduce((a, b) => a + b, 0)
// @ts-ignore
const shards = ctx.client.shard?.count
// @ts-ignore
const users = (await ctx.client.shard?.fetchClientValues(`users.cache.size`))?.reduce((a, b) => a + b, 0)
let MiscValues = [

View File

@ -1,8 +1,8 @@
import Command from '../../handler/structures/Command';
import { Context } from '../../utils/types';
import language from '../../utils/language';
import { Command } from '@thaldrin/eu';
import { Context } from '../../../utils/types';
import language from '../../../utils/language';
import { Guild, GuildMember, MessageEmbed, User as DiscordUser } from 'discord.js';
import replace from '../../utils/replace';
import replace from '../../../utils/replace';
let MentionRegex = /^<@!?(\d+)>$/gi

View File

@ -1,9 +1,9 @@
import Command from '../../handler/structures/Command';
import { Context } from '../../utils/types';
import SendWS from "../../utils/webhook";
import language from '../../utils/language';
import { bug } from '../../utils/trello';
import replace from '../../utils/replace';
import { Command } from '@thaldrin/eu';
import { Context } from '../../../utils/types';
import SendWS from "../../../utils/webhook";
import language from '../../../utils/language';
import { bug } from '../../../utils/trello';
import replace from '../../../utils/replace';
export = class Suggestion extends Command {
constructor() {
super({

View File

@ -1,7 +1,7 @@
import Command from "../../handler/structures/Command";
import { Context } from "../../utils/types";
import lingua from "../../utils/lingua";
import replace from "../../utils/replace";
import { Command } from '@thaldrin/eu';
import { Context } from "../../../utils/types";
import lingua from "../../../utils/lingua";
import replace from "../../../utils/replace";
import { MessageEmbed } from "discord.js";
let perks = [

View File

@ -1,8 +1,8 @@
import yiff from "../../utils/yiff"
import Command from "../../handler/structures/Command"
import { Context } from "../../utils/types";
import yiff from "../../../utils/yiff"
import { Command } from '@thaldrin/eu';
import { Context } from "../../../utils/types";
import { MessageEmbed } from "discord.js"
import language from "../../utils/language";
import language from "../../../utils/language";
export = class E926 extends Command {
constructor() {
super({

View File

@ -1,7 +1,7 @@
import Command from '../../handler/structures/Command';
import { Context } from '../../utils/types';
import language from '../../utils/language';
import { Folders, Commands } from "../../utils/command.amount";
import { Command } from '@thaldrin/eu';
import { Context } from '../../../utils/types';
import language from '../../../utils/language';
import { Folders, Commands } from "../../../utils/command.amount";
import { MessageEmbed } from 'discord.js';
export = class Help extends Command {
@ -31,6 +31,7 @@ export = class Help extends Command {
let arg = ctx.args[0]
if (await (await Folders()).includes(arg)) {
if (arg === 'developer' && !ctx.isDeveloper) return
// @ts-ignore
let commands = await (await Commands(arg, ctx.client)).map(command => `\`${command.name}\` - ${command.description}`)
embed.addField("Commands", commands.join("\n"))
// @ts-ignore

View File

@ -1,7 +1,8 @@
import Command from '../../handler/structures/Command';
import { Context } from '../../utils/types';
import language from '../../utils/language';
import replace from '../../utils/replace';
import { Command } from '@thaldrin/eu';
import { Context } from '../../../utils/types';
import language from '../../../utils/language';
import replace from '../../../utils/replace';
export = class Invite extends Command {
constructor() {

View File

@ -1,8 +1,8 @@
import Command from '../../handler/structures/Command';
import { Context, Server } from '../../utils/types';
import database from "../../utils/database"
import language from '../../utils/language';
import replace from '../../utils/replace';
import { Command } from '@thaldrin/eu';
import { Context, Server } from '../../../utils/types';
import database from "../../../utils/database"
import language from '../../../utils/language';
import replace from '../../../utils/replace';
import { MessageEmbed } from 'discord.js';
export = class Prefix extends Command {
constructor() {

View File

@ -1,7 +1,7 @@
import Command from "../../handler/structures/Command";
import { Context } from "../../utils/types";
import language from "../../utils/language";
import replace from "../../utils/replace";
import { Command } from '@thaldrin/eu';
import { Context } from "../../../utils/types";
import language from "../../../utils/language";
import replace from "../../../utils/replace";
import Roll from 'roll'
const roll = new Roll()

View File

@ -1,8 +1,8 @@
import Command from '../../handler/structures/Command';
import { Context } from '../../utils/types';
import SendWS from "../../utils/webhook";
import language from '../../utils/language';
import { suggest } from '../../utils/trello';
import { Command } from '@thaldrin/eu';
import { Context } from '../../../utils/types';
import SendWS from "../../../utils/webhook";
import language from '../../../utils/language';
import { suggest } from '../../../utils/trello';
export = class Suggestion extends Command {
constructor() {
super({

View File

@ -1,10 +1,10 @@
// @ts-nocheck
import Command from '../../handler/structures/Command';
import { Context } from '../../utils/types';
import { Command } from '@thaldrin/eu';
import { Context } from '../../../utils/types';
import { MessageEmbed } from 'discord.js';
import language from '../../utils/language';
import replace from '../../utils/replace';
import { request } from '../../utils/command.roleplay';
import language from '../../../utils/language';
import replace from '../../../utils/replace';
import { request } from '../../../utils/command.roleplay';
export = class Bulge extends Command {
constructor() {

View File

@ -1,8 +1,8 @@
import yiff from "../../utils/yiff"
import Command from "../../handler/structures/Command"
import { Context } from "../../utils/types";
import yiff from "../../../utils/yiff"
import { Command } from '@thaldrin/eu';
import { Context } from "../../../utils/types";
import { MessageEmbed } from "discord.js"
import language from "../../utils/language";
import language from "../../../utils/language";
export = class E621 extends Command {
constructor() {
super({

View File

@ -1,10 +1,9 @@
// @ts-nocheck
import Command from '../../handler/structures/Command';
import { Context } from '../../utils/types';
import { Command } from '@thaldrin/eu';
import { MessageEmbed } from 'discord.js';
import language from '../../utils/language';
import replace from '../../utils/replace';
import { request } from '../../utils/command.roleplay';
import language from '../../../utils/language';
import replace from '../../../utils/replace';
import { request } from '../../../utils/command.roleplay';
export = class NSFW_Cuddle extends Command {
constructor() {

View File

@ -1,16 +1,16 @@
// @ts-nocheck
import Command from '../../handler/structures/Command';
import { Context } from '../../utils/types';
import { Command } from '@thaldrin/eu';
import { Context } from '../../../utils/types';
import { MessageEmbed } from 'discord.js';
import language from '../../utils/language';
import replace from '../../utils/replace';
import { request } from '../../utils/command.roleplay';
import language from '../../../utils/language';
import replace from '../../../utils/replace';
import { request } from '../../../utils/command.roleplay';
export = class NSFW_Hold extends Command {
constructor() {
super({
name: "nhold",
description: "Hug somebody!",
description: "Hold somebody!",
cooldown: 1,
nsfw: true,
usage: `<@User>`

View File

@ -1,10 +1,10 @@
// @ts-nocheck
import Command from '../../handler/structures/Command';
import { Context } from '../../utils/types';
import { Command } from '@thaldrin/eu';
import { Context } from '../../../utils/types';
import { MessageEmbed } from 'discord.js';
import language from '../../utils/language';
import replace from '../../utils/replace';
import { request } from '../../utils/command.roleplay';
import language from '../../../utils/language';
import replace from '../../../utils/replace';
import { request } from '../../../utils/command.roleplay';
export = class NSFW_Hug extends Command {
constructor() {

View File

@ -1,10 +1,10 @@
// @ts-nocheck
import Command from '../../handler/structures/Command';
import { Context } from '../../utils/types';
import { Command } from '@thaldrin/eu';
import { Context } from '../../../utils/types';
import { MessageEmbed } from 'discord.js';
import language from '../../utils/language';
import replace from '../../utils/replace';
import { request } from '../../utils/command.roleplay';
import language from '../../../utils/language';
import replace from '../../../utils/replace';
import { request } from '../../../utils/command.roleplay';
export = class NSFW_Kiss extends Command {
constructor() {

View File

@ -1,10 +1,10 @@
// @ts-nocheck
import Command from '../../handler/structures/Command';
import { Context } from '../../utils/types';
import { Command } from '@thaldrin/eu';
import { Context } from '../../../utils/types';
import { MessageEmbed } from 'discord.js';
import language from '../../utils/language';
import replace from '../../utils/replace';
import { request } from '../../utils/command.roleplay';
import language from '../../../utils/language';
import replace from '../../../utils/replace';
import { request } from '../../../utils/command.roleplay';
export = class NSFW_Lick extends Command {
constructor() {

View File

@ -1,5 +1,5 @@
import Logger from "../utils/logger"
import config from "../../config"
import Logger from "../../utils/logger"
import config from "../../../config"
import { Guild } from "discord.js"
// import Prom from "../utils/init.prometheus";
export = {

View File

@ -1,16 +1,18 @@
// @ts-nocheck
import { Client, Collection, Message, MessageEmbed } from "discord.js";
import Logger from "../utils/logger";
import supabase from "../utils/database";
import { Command, Server, Usage } from "../utils/types";
import config from "../../config";
import { Commands, Shortlink, SourceFinder } from "../utils/wrapper.features";
import language from "../utils/language";
import replace from "../utils/replace";
import Logger from "../../utils/logger";
import supabase from "../../utils/database";
import { Command, Server, Usage } from "../../utils/types";
import config from "../../../config";
import { Commands, Shortlink, SourceFinder } from "../../utils/wrapper.features";
import mod from "../../utils/database";
import language from "../../utils/language";
import replace from "../../utils/replace";
import chalk from "chalk";
// import Prom from "../utils/init.prometheus";
export = {
name: "message",
run: async (client: Client, message: Message) => {
@ -18,35 +20,35 @@ export = {
if (message.author.bot) return
if (message.channel.type === "dm") return
// ! Messages seen
let { data: usage_data, error: usage_error } = await supabase.from<Usage>("usage").select().eq('name', "message")
if (usage_data?.length === 0) {
let { data: a, error: b } = await supabase.from<Usage>("usage").insert({ name: "message", type: "event" }).select()
usage_data = a
}
let { data: updated_usage_data, error } = await supabase.from<Usage>('usage').update({ amount: usage_data[0].amount + 1 }).select().eq("name", "message")
// ! Messages seen
// // ! Messages seen
// let { data: usage_data, error: usage_error } = await supabase.from<Usage>("usage").select().eq('name', "message")
// if (usage_data?.length === 0) {
// let { data: a, error: b } = await supabase.from<Usage>("usage").insert({ name: "message", type: "event" }).select()
// usage_data = a
// }
// let { data: updated_usage_data, error } = await supabase.from<Usage>('usage').update({ amount: usage_data[0].amount + 1 }).select().eq("name", "message")
// // ! Messages seen
// ? Check if Server exists in DB
let { data: check_data, error: check_error } = await supabase.from<Server>("servers").select().eq(`server_id`, message.guild.id).limit(1)
if (check_data?.length === 0) {
let { data: c, error: d } = await supabase.from<Server>('servers').insert({
server_id: message.guild?.id
})
}
// ? Get Server Config
let { data: server_data, error: server_error } = await supabase.from<Server>("servers").select().eq(`server_id`, message.guild.id).limit(1)
// // ? Check if Server exists in DB
// let { data: check_data, error: check_error } = await supabase.from<Server>("servers").select().eq(`server_id`, message.guild.id).limit(1)
// if (check_data?.length === 0) {
// let { data: c, error: d } = await supabase.from<Server>('servers').insert({
// server_id: message.guild?.id
// })
// }
// // ? Get Server Config
// let { data: server_data, error: server_error } = await supabase.from<Server>("servers").select().eq(`server_id`, message.guild.id).limit(1)
let server_data = await mod.server(message.guild.id)
// ? Check if Message includes Shortlinks
await Shortlink(message, server_data[0].shortlinks)
await Shortlink(message, server_data.shortlinks)
// ? Check if Message includes E621 Image Links
await SourceFinder(message, server_data[0].sourcefinder)
await SourceFinder(message, server_data.sourcefinder)
// ? Check if Channel Topic allows Commands
if (await Commands(message)) return;
// ! Prefix
let PrefixArray: string[] = [...config.variables.prefix, [(server_data[0].prefix ? server_data[0].prefix : [])]].flat(Infinity)
let PrefixArray: string[] = [...config.variables.prefix, [(server_data.prefix ? server_data.prefix : [])]].flat(Infinity)
let Prefix: string
let Exists: boolean
@ -75,9 +77,9 @@ export = {
message, channel: message.channel,
author: message.author,
member: message.member,
supabase,
modulus: mod,
language,
settings: server_data[0],
settings: server_data,
config,
isDeveloper: config.variables.developers.find(dev => dev.id === message.author.id)
}
@ -113,19 +115,19 @@ export = {
try {
await cmd.command(ctx)
// ? Check if Comnand exists in DB
let { data: usage_check_data, error: usage_check_error } = await supabase.from<Usage>("usage").select().eq(`name`, cmd.name).limit(1)
if (usage_check_data?.length == 0) {
let { data: c, error: d } = await supabase.from<Usage>('usage').insert({
name: cmd.name,
type: "command",
// amount: 1
})
// // ? Check if Comnand exists in DB
// let { data: usage_check_data, error: usage_check_error } = await supabase.from<Usage>("usage").select().eq(`name`, cmd.name).limit(1)
// if (usage_check_data?.length == 0) {
// let { data: c, error: d } = await supabase.from<Usage>('usage').insert({
// name: cmd.name,
// type: "command",
// // amount: 1
// })
}
// }
// Prom.commandsExecuted.inc()
let { data: command_usage_data, command_usage_error } = await supabase.from<Usage>('usage').update({ amount: (usage_check_data[0] || { amount: 0 }).amount + 1 }).select().eq("name", cmd.name)
// let { data: command_usage_data, command_usage_error } = await supabase.from<Usage>('usage').update({ amount: (usage_check_data[0] || { amount: 0 }).amount + 1 }).select().eq("name", cmd.name)
Logger.info({
type: "command:executed",
command: cmd.name,

View File

@ -1,5 +1,5 @@
import Logger from "../utils/logger"
import config from "../../config"
import Logger from "../../utils/logger"
import config from "../../../config"
// import prom from "../utils/init.prometheus"
export = {
name: "ready",

View File

@ -1,4 +1,4 @@
import Logger from "../utils/logger"
import Logger from "../../utils/logger"
import { Guild } from "discord.js"
// import Prom from "../utils/init.prometheus";
export = {

View File

@ -1,5 +1,5 @@
import { Client, Message } from "discord.js";
import Logger from "../utils/logger";
import Logger from "../../utils/logger";
export = {
@ -9,7 +9,7 @@ export = {
if (old_message.content === new_message.content) return;
// Logger.info({ type: `event:messageUpdate`, message: "Emitting new message to event:message" })
// Logger.info({ type: `event:messageUpdate`, message: "Emitting new message to event:message" })
await client.emit("message", new_message)
}

View File

@ -1,73 +0,0 @@
import { Client, Collection } from "discord.js";
import { readdirSync as read } from "fs";
import path from "path";
import { Command } from "../../utils/types";
import Logger from "../../utils/logger";
// import { Prom } from "../../utils/prometheus";
// const server = require('../../website/server');
export default class Thaldrin extends Client {
commands: Collection<string, Command>;
cooldowns: Collection<unknown, unknown>;
config: any;
lastEval: any;
constructor(config: { token: any; }) {
super({
// disableEveryone: true,
// disabledEvents: ['TYPING_START'],
// shardCount: shards,
// totalShardCount: shards
});
this.commands = new Collection();
this.cooldowns = new Collection();
// this.queues = new Collection();
this.config = config;
this.lastEval = null;
// @ts-ignore
// this.on("raw", packet => {
// Prom.events.labels(packet.t).inc()
// })
this.login(config.token);
this.load();
}
async load() {
const events = await read(path.join(__dirname, '../../events'));
const modules = await read(path.join(__dirname, '../../modules'));
// server(this);
events.filter((f) => f.endsWith('.js')).forEach((file) => {
try {
const event = require(path.join(__dirname, '../../events', file));
this.on(event.name, event.run.bind(null, this));
} catch (err) {
console.error(err);
}
});
modules.filter((f) => !f.endsWith('.js')).forEach(async (module) => {
const commands = await read(path.join(__dirname, '../../modules', module));
commands.filter((f) => f.endsWith('.js')).forEach((command) => {
try {
const file = require(path.join(__dirname, '../../modules', module, command));
const Command = new file();
Command.module = module
// Logger.info({
// type: "command:loaded",
// command: Command.name,
// message: `${Command.name}:${Command.module} was loaded`
// })
this.commands.set(Command.name, Command);
} catch (err) {
console.error(err);
}
});
});
}
};

View File

@ -1,32 +0,0 @@
import { Context, Command as CommandContext } from "../../utils/types";
export default class Command {
name: string;
description: string;
aliases: string[];
module: string;
cooldown: number;
guild: boolean;
dev: boolean;
nsfw: boolean;
AuthorPermissions: string | string[];
hidden: boolean;
usage: string
constructor(command: CommandContext) {
this.name = command.name || "generic";
this.description = command.description || "generic command base";
this.aliases = command.aliases || [];
this.module = command.module || "";
this.cooldown = command.cooldown || 1;
this.guild = command.guild || false;
this.dev = command.dev || false;
this.nsfw = command.nsfw || false;
this.AuthorPermissions = command.AuthorPermissions || "NONE";
this.hidden = command.hidden || false;
this.usage = command.usage || ''
}
async run(ctx: Context) {
ctx.channel.send("This is the default command, overwrite me.")
}
};