Updated event layout
This commit is contained in:
@@ -4,25 +4,24 @@ import { IEvent } from "~/interfaces"
|
|||||||
import { dateTimeFormatter } from "~/utils/Functions/intlFormaters.js"
|
import { dateTimeFormatter } from "~/utils/Functions/intlFormaters.js"
|
||||||
import logToChannel from "~/utils/Functions/logtochannel.js"
|
import logToChannel from "~/utils/Functions/logtochannel.js"
|
||||||
|
|
||||||
export default {
|
const event: IEvent<"guildMemberAdd"> = (member) => {
|
||||||
event: "guildMemberAdd",
|
if (process.env.NODE_ENV === "dev") return
|
||||||
execute(member) {
|
logToChannel("bot", {
|
||||||
if (process.env.NODE_ENV === "dev") return
|
embeds: [{
|
||||||
logToChannel("bot", {
|
title: "New Member",
|
||||||
embeds: [{
|
description: userMention(member.id) + " has joined the server.\n" +
|
||||||
title: "New Member",
|
"Account created: " + dateTimeFormatter(member.user.createdAt),
|
||||||
description: userMention(member.id) + " has joined the server.\n" +
|
color: embedColor,
|
||||||
"Account created: " + dateTimeFormatter(member.user.createdAt),
|
thumbnail: {
|
||||||
color: embedColor,
|
url: member.user.avatarURL() || ""
|
||||||
thumbnail: {
|
},
|
||||||
url: member.user.avatarURL() || ""
|
footer: {
|
||||||
},
|
text: "ID: " + member.id,
|
||||||
footer: {
|
icon_url: member.user.avatarURL() || undefined
|
||||||
text: "ID: " + member.id,
|
},
|
||||||
icon_url: member.user.avatarURL() || undefined
|
timestamp: new Date().toISOString()
|
||||||
},
|
}]
|
||||||
timestamp: new Date().toISOString()
|
})
|
||||||
}]
|
}
|
||||||
})
|
|
||||||
}
|
export default event
|
||||||
} as IEvent<"guildMemberAdd">
|
|
||||||
|
|||||||
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 { IEvent } from "~/interfaces"
|
||||||
import { log } from "~/utils/Logger.js"
|
import { log } from "~/utils/Logger.js"
|
||||||
|
|
||||||
export default {
|
const event: IEvent<"ready"> = (client) => {
|
||||||
event: "ready",
|
log("Logged in as " + client.user!.tag + "!", "info", { type: "preset", color: "green" })
|
||||||
execute(client) {
|
}
|
||||||
log("Logged in as " + client.user!.tag + "!", "info", { type: "preset", color: "green" })
|
|
||||||
}
|
export default event
|
||||||
} as IEvent<"ready">
|
|
||||||
|
|||||||
@@ -2,16 +2,15 @@ import { embedColor } from "~/config/options.js"
|
|||||||
import { IEvent } from "~/interfaces"
|
import { IEvent } from "~/interfaces"
|
||||||
import logToChannel from "~/utils/Functions/logtochannel.js"
|
import logToChannel from "~/utils/Functions/logtochannel.js"
|
||||||
|
|
||||||
export default {
|
const event: IEvent<"ready"> = () => {
|
||||||
event: "ready",
|
if (process.env.NODE_ENV === "dev") return
|
||||||
execute() {
|
|
||||||
if (process.env.NODE_ENV === "dev") return
|
|
||||||
|
|
||||||
logToChannel("online", {
|
logToChannel("online", {
|
||||||
embeds: [{
|
embeds: [{
|
||||||
description: "Bot is online!",
|
description: "Bot is online!",
|
||||||
color: embedColor
|
color: embedColor
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} as IEvent<"ready">
|
|
||||||
|
export default event
|
||||||
|
|||||||
@@ -3,28 +3,27 @@ import { guildid } from "~/config/options.js"
|
|||||||
import statuses from "~/config/statuses.js"
|
import statuses from "~/config/statuses.js"
|
||||||
import { IEvent } from "~/interfaces"
|
import { IEvent } from "~/interfaces"
|
||||||
|
|
||||||
export default {
|
const event: IEvent<"ready"> = (client) => {
|
||||||
event: "ready",
|
const user = client.user!
|
||||||
execute(client) {
|
const guild = client.guilds.cache.get(guildid) as Guild
|
||||||
const user = client.user!
|
|
||||||
const guild = client.guilds.cache.get(guildid) as Guild
|
|
||||||
|
|
||||||
function getActivity(status: ((guild: Guild) => string) | string): string {
|
function getActivity(status: ((guild: Guild) => string) | string): string {
|
||||||
if (typeof status === "function") {
|
if (typeof status === "function") {
|
||||||
return status(guild)
|
return status(guild)
|
||||||
} else {
|
} else {
|
||||||
return status
|
return status
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
user.setActivity({ name: getActivity(statuses[0].name), type: statuses[0].type })
|
|
||||||
|
|
||||||
let i = 1
|
|
||||||
setInterval(() => {
|
|
||||||
const status = i++ % statuses.length
|
|
||||||
user.setActivity({ name: getActivity(statuses[status].name), type: statuses[status].type })
|
|
||||||
}, 1000 * 60)
|
|
||||||
|
|
||||||
user.setStatus("dnd")
|
|
||||||
}
|
}
|
||||||
} as IEvent<"ready">
|
|
||||||
|
user.setActivity({ name: getActivity(statuses[0].name), type: statuses[0].type })
|
||||||
|
|
||||||
|
let i = 1
|
||||||
|
setInterval(() => {
|
||||||
|
const status = i++ % statuses.length
|
||||||
|
user.setActivity({ name: getActivity(statuses[status].name), type: statuses[status].type })
|
||||||
|
}, 1000 * 60)
|
||||||
|
|
||||||
|
user.setStatus("dnd")
|
||||||
|
}
|
||||||
|
|
||||||
|
export default event
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
import { IEvent } from "~/interfaces"
|
import { IEvent } from "~/interfaces"
|
||||||
|
|
||||||
export default {
|
const event: IEvent<"voiceStateUpdate"> = (_o, n) => {
|
||||||
event: "voiceStateUpdate",
|
const guild = n.guild
|
||||||
async execute(_o, n) {
|
|
||||||
const guild = n.guild
|
|
||||||
|
|
||||||
if (!guild) return
|
if (!guild) return
|
||||||
|
|
||||||
if (!n.channel) {
|
if (!n.channel) {
|
||||||
guild.voiceStates.cache.delete(n.id)
|
guild.voiceStates.cache.delete(n.id)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} as IEvent<"voiceStateUpdate">
|
}
|
||||||
|
|
||||||
|
export default event
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { ClientEvents } from "discord.js"
|
import { ClientEvents } from "discord.js"
|
||||||
|
|
||||||
export default interface IEvent<E extends keyof ClientEvents> {
|
type IEvent<E extends keyof ClientEvents> = (...args: ClientEvents[E]) => void
|
||||||
event: E
|
|
||||||
execute(...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)
|
const eventDirs = fs.readdirSync(serverDir)
|
||||||
for (const eventDir of eventDirs) {
|
for (const eventDir of eventDirs) {
|
||||||
const eventFiles = fs.readdirSync(path.join(serverDir, eventDir)).filter(file => file.endsWith(ft))
|
const eventFiles = fs.readdirSync(path.join(serverDir, eventDir)).filter(file => file.endsWith(ft))
|
||||||
|
const eventName = 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)
|
const { default: event } = await import("file://" + eventPath)
|
||||||
if (!event.disabled) {
|
client.on(eventName, event)
|
||||||
client.on(event.event, event.execute)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user