Changed the event handler
This commit is contained in:
@@ -4,10 +4,7 @@ import { IEvent } from "interfaces"
|
|||||||
import logToChannel from "utils/functions/logtochannel.js"
|
import logToChannel from "utils/functions/logtochannel.js"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "logNewJoins",
|
|
||||||
description: "Logs new joins",
|
|
||||||
event: "guildMemberAdd",
|
event: "guildMemberAdd",
|
||||||
|
|
||||||
execute(member: GuildMember) {
|
execute(member: GuildMember) {
|
||||||
if (process.env.NODE_ENV === "dev") return
|
if (process.env.NODE_ENV === "dev") return
|
||||||
logToChannel("bot", {
|
logToChannel("bot", {
|
||||||
@@ -27,4 +24,4 @@ export default {
|
|||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} as IEvent
|
} as IEvent<"guildMemberAdd">
|
||||||
|
|||||||
@@ -1,14 +1,10 @@
|
|||||||
import { ButtonInteraction, ChatInputCommandInteraction } from "discord.js"
|
|
||||||
import { IEvent } from "interfaces"
|
import { IEvent } from "interfaces"
|
||||||
import { color } from "utils/functions/colors.js"
|
import { color } from "utils/functions/colors.js"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "logBtnsCmds",
|
|
||||||
description: "Logs all button and command interactions",
|
|
||||||
event: "interactionCreate",
|
event: "interactionCreate",
|
||||||
|
execute(interaction) {
|
||||||
execute(interaction: ChatInputCommandInteraction | ButtonInteraction) {
|
if (interaction.isChatInputCommand()) {
|
||||||
if (interaction.isCommand()) {
|
|
||||||
let subcommand: string | null
|
let subcommand: string | null
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -60,4 +56,4 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} as IEvent
|
} as IEvent<"interactionCreate">
|
||||||
|
|||||||
@@ -1,14 +1,10 @@
|
|||||||
import { ChannelType, Message } from "discord.js"
|
import { ChannelType } from "discord.js"
|
||||||
import { IEvent } from "interfaces"
|
import { IEvent } from "interfaces"
|
||||||
import env from "utils/Env.js"
|
import env from "utils/Env.js"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "eval",
|
|
||||||
description: "Evaluate a JavaScript expression",
|
|
||||||
event: "messageCreate",
|
event: "messageCreate",
|
||||||
disabled: true,
|
async execute(message) {
|
||||||
|
|
||||||
async execute(message: Message) {
|
|
||||||
if (message.author.bot) return
|
if (message.author.bot) return
|
||||||
if (message.author.id !== env.prod.dev) return
|
if (message.author.id !== env.prod.dev) return
|
||||||
if (!message.content.startsWith("!eval")) return
|
if (!message.content.startsWith("!eval")) return
|
||||||
@@ -34,4 +30,4 @@ export default {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} as IEvent
|
} as IEvent<"messageCreate">
|
||||||
|
|||||||
@@ -1,14 +1,10 @@
|
|||||||
import { Message } from "discord.js"
|
|
||||||
import { IEvent } from "interfaces"
|
import { IEvent } from "interfaces"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "ur mom",
|
|
||||||
description: "ur moms someone",
|
|
||||||
event: "messageCreate",
|
event: "messageCreate",
|
||||||
|
async execute(message) {
|
||||||
async execute(message: Message) {
|
|
||||||
if (message.content.toLowerCase().includes("ur mom") && message.author.username === "taken.lua") {
|
if (message.content.toLowerCase().includes("ur mom") && message.author.username === "taken.lua") {
|
||||||
message.react("Woot:734345936347725885")
|
message.react("Woot:734345936347725885")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} as IEvent
|
} as IEvent<"messageCreate">
|
||||||
|
|||||||
@@ -1,13 +1,9 @@
|
|||||||
import { IEvent } from "interfaces"
|
import { IEvent } from "interfaces"
|
||||||
import { ExtendedClient as Client } from "utils/Client.js"
|
|
||||||
import { color } from "utils/functions/colors.js"
|
import { color } from "utils/functions/colors.js"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "conolelog",
|
|
||||||
description: "console log",
|
|
||||||
event: "ready",
|
event: "ready",
|
||||||
|
execute(client) {
|
||||||
execute(client: Client) {
|
|
||||||
console.log(color("Logged in as " + client.user!.tag + "!", "green"))
|
console.log(color("Logged in as " + client.user!.tag + "!", "green"))
|
||||||
}
|
}
|
||||||
} as IEvent
|
} as IEvent<"ready">
|
||||||
|
|||||||
@@ -3,10 +3,7 @@ import { IEvent } from "interfaces"
|
|||||||
import logToChannel from "utils/functions/logtochannel.js"
|
import logToChannel from "utils/functions/logtochannel.js"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "sendonlinemessage",
|
|
||||||
description: "send an online message",
|
|
||||||
event: "ready",
|
event: "ready",
|
||||||
|
|
||||||
execute() {
|
execute() {
|
||||||
if (process.env.NODE_ENV === "dev") return
|
if (process.env.NODE_ENV === "dev") return
|
||||||
|
|
||||||
@@ -17,4 +14,4 @@ export default {
|
|||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} as IEvent
|
} as IEvent<"ready">
|
||||||
|
|||||||
@@ -2,14 +2,10 @@ import { guildid } from "config/options.js"
|
|||||||
import statuses from "config/statuses.js"
|
import statuses from "config/statuses.js"
|
||||||
import { Guild } from "discord.js"
|
import { Guild } from "discord.js"
|
||||||
import { IEvent } from "interfaces"
|
import { IEvent } from "interfaces"
|
||||||
import { ExtendedClient as Client } from "utils/Client.js"
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "status",
|
|
||||||
description: "Sets the status of the bot",
|
|
||||||
event: "ready",
|
event: "ready",
|
||||||
|
execute(client) {
|
||||||
execute(client: Client) {
|
|
||||||
const user = client.user!
|
const user = client.user!
|
||||||
const guild = client.guilds.cache.get(guildid) as Guild
|
const guild = client.guilds.cache.get(guildid) as Guild
|
||||||
|
|
||||||
@@ -31,4 +27,4 @@ export default {
|
|||||||
|
|
||||||
user.setStatus("dnd")
|
user.setStatus("dnd")
|
||||||
}
|
}
|
||||||
} as IEvent
|
} as IEvent<"ready">
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
import { VoiceState } from "discord.js"
|
|
||||||
import { IEvent } from "interfaces"
|
import { IEvent } from "interfaces"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "updatecache",
|
|
||||||
description: "Updates the voice states cache",
|
|
||||||
event: "voiceStateUpdate",
|
event: "voiceStateUpdate",
|
||||||
|
async execute(_o, n) {
|
||||||
async execute(_o: VoiceState, n: VoiceState) {
|
|
||||||
const guild = n.guild
|
const guild = n.guild
|
||||||
|
|
||||||
if (!guild) return
|
if (!guild) return
|
||||||
@@ -15,4 +11,4 @@ export default {
|
|||||||
guild.voiceStates.cache.delete(n.id)
|
guild.voiceStates.cache.delete(n.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} as IEvent
|
} as IEvent<"voiceStateUpdate">
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
import { ClientEvents } from "discord.js"
|
import { ClientEvents } from "discord.js"
|
||||||
|
|
||||||
export default interface IEvent {
|
export default interface IEvent<E extends keyof ClientEvents> {
|
||||||
name: string
|
event: E
|
||||||
description: string
|
execute(...args: ClientEvents[E]): void
|
||||||
event: keyof ClientEvents
|
|
||||||
disabled?: boolean
|
|
||||||
execute(...args: any[]): void
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import fs from "fs"
|
import fs from "fs"
|
||||||
import { IEvent } from "interfaces"
|
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { ExtendedClient as Client } from "utils/Client.js"
|
import { ExtendedClient as Client } from "utils/Client.js"
|
||||||
const __dirname = import.meta.dirname
|
const __dirname = import.meta.dirname
|
||||||
@@ -11,7 +10,7 @@ export default async function loadEvents(client: Client) {
|
|||||||
const eventFiles = fs.readdirSync(path.join(serverDir, eventDir))
|
const eventFiles = fs.readdirSync(path.join(serverDir, eventDir))
|
||||||
for (const eventFile of eventFiles) {
|
for (const eventFile of eventFiles) {
|
||||||
const eventPath = path.join(serverDir, eventDir, eventFile)
|
const eventPath = path.join(serverDir, eventDir, eventFile)
|
||||||
const { default: event } = await import("file://" + eventPath) as { default: IEvent }
|
const { default: event } = await import("file://" + eventPath)
|
||||||
if (!event.disabled) {
|
if (!event.disabled) {
|
||||||
client.on(event.event, event.execute)
|
client.on(event.event, event.execute)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user