Merge branch 'dev' into 'main'
Dev See merge request illegitimate/illegitimate-bot!322
This commit is contained in:
@@ -4,25 +4,24 @@ import { IEvent } from "~/interfaces"
|
||||
import { dateTimeFormatter } from "~/utils/Functions/intlFormaters.js"
|
||||
import logToChannel from "~/utils/Functions/logtochannel.js"
|
||||
|
||||
export default {
|
||||
event: "guildMemberAdd",
|
||||
execute(member) {
|
||||
if (process.env.NODE_ENV === "dev") return
|
||||
logToChannel("bot", {
|
||||
embeds: [{
|
||||
title: "New Member",
|
||||
description: userMention(member.id) + " has joined the server.\n" +
|
||||
"Account created: " + dateTimeFormatter(member.user.createdAt),
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: member.user.avatarURL() || ""
|
||||
},
|
||||
footer: {
|
||||
text: "ID: " + member.id,
|
||||
icon_url: member.user.avatarURL() || undefined
|
||||
},
|
||||
timestamp: new Date().toISOString()
|
||||
}]
|
||||
})
|
||||
}
|
||||
} as IEvent<"guildMemberAdd">
|
||||
const event: IEvent<"guildMemberAdd"> = (member) => {
|
||||
if (process.env.NODE_ENV === "dev") return
|
||||
logToChannel("bot", {
|
||||
embeds: [{
|
||||
title: "New Member",
|
||||
description: userMention(member.id) + " has joined the server.\n" +
|
||||
"Account created: " + dateTimeFormatter(member.user.createdAt),
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: member.user.avatarURL() || ""
|
||||
},
|
||||
footer: {
|
||||
text: "ID: " + member.id,
|
||||
icon_url: member.user.avatarURL() || undefined
|
||||
},
|
||||
timestamp: new Date().toISOString()
|
||||
}]
|
||||
})
|
||||
}
|
||||
|
||||
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) {
|
||||
log("Logged in as " + client.user!.tag + "!", "info", { type: "preset", color: "green" })
|
||||
}
|
||||
} as IEvent<"ready">
|
||||
const event: IEvent<"ready"> = (client) => {
|
||||
log("Logged in as " + client.user!.tag + "!", "info", { type: "preset", color: "green" })
|
||||
}
|
||||
|
||||
export default event
|
||||
|
||||
@@ -2,16 +2,15 @@ import { embedColor } from "~/config/options.js"
|
||||
import { IEvent } from "~/interfaces"
|
||||
import logToChannel from "~/utils/Functions/logtochannel.js"
|
||||
|
||||
export default {
|
||||
event: "ready",
|
||||
execute() {
|
||||
if (process.env.NODE_ENV === "dev") return
|
||||
const event: IEvent<"ready"> = () => {
|
||||
if (process.env.NODE_ENV === "dev") return
|
||||
|
||||
logToChannel("online", {
|
||||
embeds: [{
|
||||
description: "Bot is online!",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
}
|
||||
} as IEvent<"ready">
|
||||
logToChannel("online", {
|
||||
embeds: [{
|
||||
description: "Bot is online!",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
}
|
||||
|
||||
export default event
|
||||
|
||||
@@ -3,28 +3,27 @@ import { guildid } from "~/config/options.js"
|
||||
import statuses from "~/config/statuses.js"
|
||||
import { IEvent } from "~/interfaces"
|
||||
|
||||
export default {
|
||||
event: "ready",
|
||||
execute(client) {
|
||||
const user = client.user!
|
||||
const guild = client.guilds.cache.get(guildid) as Guild
|
||||
const event: IEvent<"ready"> = (client) => {
|
||||
const user = client.user!
|
||||
const guild = client.guilds.cache.get(guildid) as Guild
|
||||
|
||||
function getActivity(status: ((guild: Guild) => string) | string): string {
|
||||
if (typeof status === "function") {
|
||||
return status(guild)
|
||||
} else {
|
||||
return status
|
||||
}
|
||||
function getActivity(status: ((guild: Guild) => string) | string): string {
|
||||
if (typeof status === "function") {
|
||||
return status(guild)
|
||||
} else {
|
||||
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"
|
||||
|
||||
export default {
|
||||
event: "voiceStateUpdate",
|
||||
async execute(_o, n) {
|
||||
const guild = n.guild
|
||||
const event: IEvent<"voiceStateUpdate"> = (_o, n) => {
|
||||
const guild = n.guild
|
||||
|
||||
if (!guild) return
|
||||
if (!guild) return
|
||||
|
||||
if (!n.channel) {
|
||||
guild.voiceStates.cache.delete(n.id)
|
||||
}
|
||||
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
|
||||
|
||||
@@ -6,10 +6,9 @@ import { IAutocomplete } from "~/interfaces"
|
||||
import { ExtendedClient as Client } from "~/utils/Client.js"
|
||||
import logToChannel from "~/utils/Functions/logtochannel.js"
|
||||
type FileType = "js" | "ts"
|
||||
const __dirname = import.meta.dirname
|
||||
|
||||
export default async function loadAutocompleteEvents(client: Client, ft: FileType) {
|
||||
const autocompletePath = path.join(__dirname, "..", "..", "components", "autocomplete")
|
||||
const autocompletePath = path.join(import.meta.dirname, "..", "..", "components", "autocomplete")
|
||||
const autocompleteFiles = fs.readdirSync(autocompletePath).filter(file => file.endsWith(ft))
|
||||
|
||||
for (const file of autocompleteFiles) {
|
||||
|
||||
@@ -6,10 +6,9 @@ import { IButton } from "~/interfaces"
|
||||
import { ExtendedClient as Client } from "~/utils/Client.js"
|
||||
import logToChannel from "~/utils/Functions/logtochannel.js"
|
||||
type FileType = "js" | "ts"
|
||||
const __dirname = import.meta.dirname
|
||||
|
||||
export default async function loadButtonEvents(client: Client, ft: FileType) {
|
||||
const btnPath = path.join(__dirname, "..", "..", "components", "buttons")
|
||||
const btnPath = path.join(import.meta.dirname, "..", "..", "components", "buttons")
|
||||
const btnFiles = fs.readdirSync(btnPath).filter(file => file.endsWith(ft))
|
||||
|
||||
for (const file of btnFiles) {
|
||||
|
||||
@@ -6,10 +6,9 @@ import { ICommand } from "~/interfaces"
|
||||
import { ExtendedClient as Client } from "~/utils/Client.js"
|
||||
import logToChannel from "~/utils/Functions/logtochannel.js"
|
||||
type FileType = "js" | "ts"
|
||||
const __dirname = import.meta.dirname
|
||||
|
||||
export default async function loadSlashCommandsEvents(client: Client, ft: FileType) {
|
||||
const cmdPath = path.join(__dirname, "..", "..", "commands")
|
||||
const cmdPath = path.join(import.meta.dirname, "..", "..", "commands")
|
||||
const cmdFiles = fs.readdirSync(cmdPath).filter(file => file.endsWith(ft))
|
||||
|
||||
for (const file of cmdFiles) {
|
||||
|
||||
@@ -6,10 +6,9 @@ import { IContextMenu } from "~/interfaces"
|
||||
import { ExtendedClient as Client } from "~/utils/Client.js"
|
||||
import logToChannel from "~/utils/Functions/logtochannel.js"
|
||||
type FileType = "js" | "ts"
|
||||
const __dirname = import.meta.dirname
|
||||
|
||||
export default async function loadContextMenuEvents(client: Client, ft: FileType) {
|
||||
const contextMenuPath = path.join(__dirname, "..", "..", "commands-contextmenu")
|
||||
const contextMenuPath = path.join(import.meta.dirname, "..", "..", "commands-contextmenu")
|
||||
const contextMenuFiles = fs.readdirSync(contextMenuPath).filter(file => file.endsWith(ft))
|
||||
|
||||
for (const file of contextMenuFiles) {
|
||||
|
||||
@@ -3,10 +3,9 @@ import fs from "fs"
|
||||
import path from "path"
|
||||
import { ICron } from "~/interfaces"
|
||||
type FileType = "js" | "ts"
|
||||
const __dirname = import.meta.dirname
|
||||
|
||||
export default async function loadCronEvents(ft: FileType) {
|
||||
const cronPath = path.join(__dirname, "..", "..", "events", "cron")
|
||||
const cronPath = path.join(import.meta.dirname, "..", "..", "events", "cron")
|
||||
const cronFiles = fs.readdirSync(cronPath).filter(file => file.endsWith(ft))
|
||||
|
||||
for (const file of cronFiles) {
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
import fs from "fs"
|
||||
import path from "path"
|
||||
import { ExtendedClient as Client } from "~/utils/Client.js"
|
||||
const __dirname = import.meta.dirname
|
||||
type FileType = "js" | "ts"
|
||||
|
||||
export default async function loadEvents(client: Client, ft: FileType) {
|
||||
const serverDir = path.join(__dirname, "..", "..", "events", "server")
|
||||
const serverDir = path.join(import.meta.dirname, "..", "..", "events", "server")
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,9 @@ import { IModal } from "~/interfaces"
|
||||
import { ExtendedClient as Client } from "~/utils/Client.js"
|
||||
import logToChannel from "~/utils/Functions/logtochannel.js"
|
||||
type FileType = "js" | "ts"
|
||||
const __dirname = import.meta.dirname
|
||||
|
||||
export default async function loadModalEvents(client: Client, ft: FileType) {
|
||||
const modalPath = path.join(__dirname, "..", "..", "components", "modals")
|
||||
const modalPath = path.join(import.meta.dirname, "..", "..", "components", "modals")
|
||||
const modalFiles = fs.readdirSync(modalPath).filter(file => file.endsWith(ft))
|
||||
|
||||
for (const file of modalFiles) {
|
||||
|
||||
Reference in New Issue
Block a user