Updated event layout
This commit is contained in:
@@ -4,9 +4,7 @@ import { IEvent } from "~/interfaces"
|
||||
import { dateTimeFormatter } from "~/utils/Functions/intlFormaters.js"
|
||||
import logToChannel from "~/utils/Functions/logtochannel.js"
|
||||
|
||||
export default {
|
||||
event: "guildMemberAdd",
|
||||
execute(member) {
|
||||
const event: IEvent<"guildMemberAdd"> = (member) => {
|
||||
if (process.env.NODE_ENV === "dev") return
|
||||
logToChannel("bot", {
|
||||
embeds: [{
|
||||
@@ -24,5 +22,6 @@ export default {
|
||||
timestamp: new Date().toISOString()
|
||||
}]
|
||||
})
|
||||
}
|
||||
} as IEvent<"guildMemberAdd">
|
||||
}
|
||||
|
||||
export default event
|
||||
|
||||
51
src/events/server/interactionCreate/logBtnsCmds.ts
Normal file
51
src/events/server/interactionCreate/logBtnsCmds.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { IEvent } from "~/interfaces"
|
||||
import { log } from "~/utils/Logger.js"
|
||||
|
||||
const event: IEvent<"interactionCreate"> = (interaction) => {
|
||||
if (interaction.isChatInputCommand()) {
|
||||
let subcommand: string | null
|
||||
|
||||
try {
|
||||
subcommand = interaction.options.getSubcommand()
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
} catch (e) {
|
||||
subcommand = null
|
||||
}
|
||||
|
||||
if (subcommand) {
|
||||
log(
|
||||
interaction.user.username + " ran " +
|
||||
interaction.commandName + " " +
|
||||
subcommand,
|
||||
"info",
|
||||
{ type: "preset", color: "pink" }
|
||||
)
|
||||
} else {
|
||||
log(
|
||||
interaction.user.username + " ran " +
|
||||
interaction.commandName,
|
||||
"info",
|
||||
{ type: "preset", color: "pink" }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (interaction.isButton()) {
|
||||
const customId = interaction.customId
|
||||
let btnId: string = ""
|
||||
|
||||
if (customId.startsWith("tempbutton-")) {
|
||||
btnId = customId.split("-")[1]
|
||||
btnId = btnId.split("-")[0]
|
||||
}
|
||||
|
||||
log(
|
||||
interaction.user.username + " clicked " + btnId,
|
||||
"info",
|
||||
{ type: "preset", color: "pink" }
|
||||
)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
export default event
|
||||
@@ -1,52 +0,0 @@
|
||||
import { IEvent } from "~/interfaces"
|
||||
import { log } from "~/utils/Logger.js"
|
||||
|
||||
export default {
|
||||
event: "interactionCreate",
|
||||
execute(interaction) {
|
||||
if (interaction.isChatInputCommand()) {
|
||||
let subcommand: string | null
|
||||
|
||||
try {
|
||||
subcommand = interaction.options.getSubcommand()
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
} catch (e) {
|
||||
subcommand = null
|
||||
}
|
||||
|
||||
if (subcommand) {
|
||||
log(
|
||||
interaction.user.username + " ran " +
|
||||
interaction.commandName + " " +
|
||||
subcommand,
|
||||
"info",
|
||||
{ type: "preset", color: "pink" }
|
||||
)
|
||||
} else {
|
||||
log(
|
||||
interaction.user.username + " ran " +
|
||||
interaction.commandName,
|
||||
"info",
|
||||
{ type: "preset", color: "pink" }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (interaction.isButton()) {
|
||||
const customId = interaction.customId
|
||||
let btnId: string = ""
|
||||
|
||||
if (customId.startsWith("tempbutton-")) {
|
||||
btnId = customId.split("-")[1]
|
||||
btnId = btnId.split("-")[0]
|
||||
}
|
||||
|
||||
log(
|
||||
interaction.user.username + " clicked " + btnId,
|
||||
"info",
|
||||
{ type: "preset", color: "pink" }
|
||||
)
|
||||
return
|
||||
}
|
||||
}
|
||||
} as IEvent<"interactionCreate">
|
||||
@@ -1,33 +0,0 @@
|
||||
import { ChannelType } from "discord.js"
|
||||
import { IEvent } from "~/interfaces"
|
||||
import env from "~/utils/Env.js"
|
||||
|
||||
export default {
|
||||
event: "messageCreate",
|
||||
async execute(message) {
|
||||
if (message.author.bot) return
|
||||
if (message.author.id !== env.prod.dev) return
|
||||
if (!message.content.startsWith("!eval")) return
|
||||
|
||||
const code = message.content.split(" ").slice(1).join(" ")
|
||||
const channel = message.channel
|
||||
|
||||
if (channel.type !== ChannelType.GuildText) return
|
||||
|
||||
try {
|
||||
const output = eval(code)
|
||||
const outputString = String(output)
|
||||
await channel.send({
|
||||
embeds: [{
|
||||
description: `\`\`\`js\n${outputString}\`\`\``
|
||||
}]
|
||||
})
|
||||
} catch (error) {
|
||||
await channel.send({
|
||||
embeds: [{
|
||||
description: `\`\`\`js\n${error}\`\`\``
|
||||
}]
|
||||
})
|
||||
}
|
||||
}
|
||||
} as IEvent<"messageCreate">
|
||||
@@ -1,10 +0,0 @@
|
||||
import { IEvent } from "~/interfaces"
|
||||
|
||||
export default {
|
||||
event: "messageCreate",
|
||||
async execute(message) {
|
||||
if (message.content.toLowerCase().includes("ur mom") && message.author.username === "taken.lua") {
|
||||
message.react("Woot:734345936347725885")
|
||||
}
|
||||
}
|
||||
} as IEvent<"messageCreate">
|
||||
@@ -1,9 +1,8 @@
|
||||
import { IEvent } from "~/interfaces"
|
||||
import { log } from "~/utils/Logger.js"
|
||||
|
||||
export default {
|
||||
event: "ready",
|
||||
execute(client) {
|
||||
const event: IEvent<"ready"> = (client) => {
|
||||
log("Logged in as " + client.user!.tag + "!", "info", { type: "preset", color: "green" })
|
||||
}
|
||||
} as IEvent<"ready">
|
||||
}
|
||||
|
||||
export default event
|
||||
|
||||
@@ -2,9 +2,7 @@ import { embedColor } from "~/config/options.js"
|
||||
import { IEvent } from "~/interfaces"
|
||||
import logToChannel from "~/utils/Functions/logtochannel.js"
|
||||
|
||||
export default {
|
||||
event: "ready",
|
||||
execute() {
|
||||
const event: IEvent<"ready"> = () => {
|
||||
if (process.env.NODE_ENV === "dev") return
|
||||
|
||||
logToChannel("online", {
|
||||
@@ -13,5 +11,6 @@ export default {
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
}
|
||||
} as IEvent<"ready">
|
||||
}
|
||||
|
||||
export default event
|
||||
|
||||
@@ -3,9 +3,7 @@ import { guildid } from "~/config/options.js"
|
||||
import statuses from "~/config/statuses.js"
|
||||
import { IEvent } from "~/interfaces"
|
||||
|
||||
export default {
|
||||
event: "ready",
|
||||
execute(client) {
|
||||
const event: IEvent<"ready"> = (client) => {
|
||||
const user = client.user!
|
||||
const guild = client.guilds.cache.get(guildid) as Guild
|
||||
|
||||
@@ -26,5 +24,6 @@ export default {
|
||||
}, 1000 * 60)
|
||||
|
||||
user.setStatus("dnd")
|
||||
}
|
||||
} as IEvent<"ready">
|
||||
}
|
||||
|
||||
export default event
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { IEvent } from "~/interfaces"
|
||||
|
||||
export default {
|
||||
event: "voiceStateUpdate",
|
||||
async execute(_o, n) {
|
||||
const event: IEvent<"voiceStateUpdate"> = (_o, n) => {
|
||||
const guild = n.guild
|
||||
|
||||
if (!guild) return
|
||||
@@ -10,5 +8,6 @@ export default {
|
||||
if (!n.channel) {
|
||||
guild.voiceStates.cache.delete(n.id)
|
||||
}
|
||||
}
|
||||
} as IEvent<"voiceStateUpdate">
|
||||
}
|
||||
|
||||
export default event
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { ClientEvents } from "discord.js"
|
||||
|
||||
export default interface IEvent<E extends keyof ClientEvents> {
|
||||
event: E
|
||||
execute(...args: ClientEvents[E]): void
|
||||
}
|
||||
type IEvent<E extends keyof ClientEvents> = (...args: ClientEvents[E]) => void
|
||||
|
||||
export default IEvent
|
||||
|
||||
@@ -8,12 +8,11 @@ export default async function loadEvents(client: Client, ft: FileType) {
|
||||
const eventDirs = fs.readdirSync(serverDir)
|
||||
for (const eventDir of eventDirs) {
|
||||
const eventFiles = fs.readdirSync(path.join(serverDir, eventDir)).filter(file => file.endsWith(ft))
|
||||
const eventName = eventDir
|
||||
for (const eventFile of eventFiles) {
|
||||
const eventPath = path.join(serverDir, eventDir, eventFile)
|
||||
const { default: event } = await import("file://" + eventPath)
|
||||
if (!event.disabled) {
|
||||
client.on(event.event, event.execute)
|
||||
}
|
||||
client.on(eventName, event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user