Merge branch 'dev' into 'main'

Dev

See merge request illegitimate/illegitimate-bot!162
This commit is contained in:
2024-01-06 23:24:32 +00:00
20 changed files with 93 additions and 243 deletions

View File

@@ -1,5 +1,6 @@
{ {
"color": "#eeaadb", "color": "#eeaadb",
"guildid": "481741000365178881",
"devMessage": "Developed by taken.lua", "devMessage": "Developed by taken.lua",
"applicationsChannel": "776705352456470550", "applicationsChannel": "776705352456470550",
"staffApplicationsChannel": "1039258641393520700", "staffApplicationsChannel": "1039258641393520700",
@@ -10,6 +11,7 @@
"botLogChannel": "1174403585149243472", "botLogChannel": "1174403585149243472",
"guildLogChannel": "1183733282534326322", "guildLogChannel": "1183733282534326322",
"errorLogChannel": "1192476369850994788", "errorLogChannel": "1192476369850994788",
"moderationLogChannel": "1193329771795447818",
"waitingListChannel": "1145773618291298384", "waitingListChannel": "1145773618291298384",
"waitingListMessage": "1146027645415473193", "waitingListMessage": "1146027645415473193",
"instructionsgif": "https://cdn.discordapp.com/attachments/838716950723952640/1188211176300089384/4DMu513uNxbM.gif?ex=6599b2e4&is=65873de4&hm=e727c7a39aacbc47d6a5453f4b5f792a45679983c30d662cd258a311381b6df0&" "instructionsgif": "https://cdn.discordapp.com/attachments/838716950723952640/1188211176300089384/4DMu513uNxbM.gif?ex=6599b2e4&is=65873de4&hm=e727c7a39aacbc47d6a5453f4b5f792a45679983c30d662cd258a311381b6df0&"

View File

@@ -1,8 +1,7 @@
import { import {
SlashCommandBuilder, SlashCommandBuilder,
PermissionFlagsBits, PermissionFlagsBits,
ChannelType, TextChannel,
GuildTextBasedChannel,
} from "discord.js" } from "discord.js"
import { color } from "../../config/options.json" import { color } from "../../config/options.json"
import { Command } from "../interfaces" import { Command } from "../interfaces"
@@ -30,7 +29,7 @@ export = {
await interaction.deferReply({ ephemeral: true }) await interaction.deferReply({ ephemeral: true })
const amount = interaction.options.getInteger("amount")! const amount = interaction.options.getInteger("amount")!
const channel2 = interaction.channel! const channel = interaction.channel as TextChannel
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
if (!amount || amount < 1 || amount > 100) { if (!amount || amount < 1 || amount > 100) {
@@ -45,20 +44,6 @@ export = {
}) })
} }
if (channel2.type !== ChannelType.GuildText) {
await interaction.editReply({
embeds: [
{
description:
"You can only clear messages in a text channel",
color: embedColor,
},
],
})
}
const channel = channel2 as GuildTextBasedChannel
channel.messages.fetch({ limit: amount }).then(async messages => { channel.messages.fetch({ limit: amount }).then(async messages => {
const messagesToDelete = messages const messagesToDelete = messages
.map(m => m) .map(m => m)

View File

@@ -1,4 +1,4 @@
import { ChatInputCommandInteraction, GuildTextBasedChannel, channelMention } from "discord.js" import { ChatInputCommandInteraction, TextChannel, channelMention } from "discord.js"
import settingsSchema from "../../schemas/settingsSchema" import settingsSchema from "../../schemas/settingsSchema"
import { color, devMessage } from "../../../config/options.json" import { color, devMessage } from "../../../config/options.json"
import mongoose from "mongoose" import mongoose from "mongoose"
@@ -6,7 +6,7 @@ import mongoose from "mongoose"
export default async function setup(interaction: ChatInputCommandInteraction): Promise<void> { export default async function setup(interaction: ChatInputCommandInteraction): Promise<void> {
await interaction.deferReply() await interaction.deferReply()
const channel = interaction.options.getChannel("channel") as GuildTextBasedChannel const channel = interaction.options.getChannel("channel") as TextChannel
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
if (await settingsSchema.findOne({ name: "counting" })) { if (await settingsSchema.findOne({ name: "counting" })) {

View File

@@ -2,7 +2,7 @@ import {
SlashCommandBuilder, SlashCommandBuilder,
PermissionFlagsBits, PermissionFlagsBits,
ChannelType, ChannelType,
GuildTextBasedChannel, TextChannel,
} from "discord.js" } from "discord.js"
import { color, devMessage } from "../../config/options.json" import { color, devMessage } from "../../config/options.json"
import { Command } from "../interfaces" import { Command } from "../interfaces"
@@ -26,7 +26,8 @@ export = {
.addChannelOption(option => .addChannelOption(option =>
option option
.setName("channel") .setName("channel")
.setDescription("The channel to send the message to."), .setDescription("The channel to send the message to.")
.addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement)
) )
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false), .setDMPermission(false),
@@ -35,32 +36,9 @@ export = {
await interaction.deferReply({ ephemeral: true }) await interaction.deferReply({ ephemeral: true })
const message = interaction.options.getString("message")! const message = interaction.options.getString("message")!
const channel2 = const channel = (interaction.options.getChannel("channel") || interaction.channel) as TextChannel
interaction.options.getChannel("channel") ?? interaction.channel
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
if (channel2?.type !== ChannelType.GuildText) {
await interaction.editReply({
embeds: [
{
description:
"You can only send a message to a text channel.",
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url:
interaction.guild!.iconURL({
forceStatic: false,
}) || undefined,
},
},
],
})
return
}
const channel = channel2 as GuildTextBasedChannel
channel.send({ channel.send({
embeds: [ embeds: [
{ {

View File

@@ -5,7 +5,7 @@ import {
ActionRowBuilder, ActionRowBuilder,
ButtonStyle, ButtonStyle,
ChannelType, ChannelType,
GuildTextBasedChannel, TextChannel,
} from "discord.js" } from "discord.js"
import { color, devMessage } from "../../config/options.json" import { color, devMessage } from "../../config/options.json"
import { Command } from "../interfaces" import { Command } from "../interfaces"
@@ -31,6 +31,7 @@ export = {
.setDescription( .setDescription(
"The channel to send the application to.", "The channel to send the application to.",
) )
.addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement)
.setRequired(true), .setRequired(true),
), ),
) )
@@ -44,6 +45,7 @@ export = {
.setDescription( .setDescription(
"The channel to send the application to.", "The channel to send the application to.",
) )
.addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement)
.setRequired(true), .setRequired(true),
), ),
) )
@@ -57,6 +59,7 @@ export = {
.setDescription( .setDescription(
"The channel to send the verfiy message to.", "The channel to send the verfiy message to.",
) )
.addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement)
.setRequired(true), .setRequired(true),
), ),
) )
@@ -70,6 +73,7 @@ export = {
.setDescription( .setDescription(
"The channel to send the waiting list message to.", "The channel to send the waiting list message to.",
) )
.addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement)
.setRequired(true), .setRequired(true),
), ),
) )
@@ -83,6 +87,7 @@ export = {
.setDescription( .setDescription(
"The channel to send the application to.", "The channel to send the application to.",
) )
.addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement)
.setRequired(true), .setRequired(true),
), ),
) )
@@ -94,17 +99,7 @@ export = {
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
if (subcommand === "sendguildapplication") { if (subcommand === "sendguildapplication") {
const channel2 = interaction.options.getChannel("channel")! const channel = interaction.options.getChannel("channel") as TextChannel
if (channel2.type !== ChannelType.GuildText) {
await interaction.reply({
content: "That channel is not a text channel.",
ephemeral: true,
})
return
}
const channel = channel2 as GuildTextBasedChannel
await channel.send({ await channel.send({
embeds: [ embeds: [
@@ -145,17 +140,7 @@ export = {
} }
if (subcommand === "sendstaffapplication") { if (subcommand === "sendstaffapplication") {
const channel2 = interaction.options.getChannel("channel")! const channel = interaction.options.getChannel("channel") as TextChannel
if (channel2.type !== ChannelType.GuildText) {
await interaction.reply({
content: "That channel is not a text channel.",
ephemeral: true,
})
return
}
const channel = channel2 as GuildTextBasedChannel
await channel.send({ await channel.send({
embeds: [ embeds: [
@@ -195,17 +180,7 @@ export = {
} }
if (subcommand === "sendinactivityapplication") { if (subcommand === "sendinactivityapplication") {
const channel2 = interaction.options.getChannel("channel")! const channel = interaction.options.getChannel("channel") as TextChannel
if (channel2.type !== ChannelType.GuildText) {
await interaction.reply({
content: "That channel is not a text channel.",
ephemeral: true,
})
return
}
const channel = channel2 as GuildTextBasedChannel
await channel.send({ await channel.send({
embeds: [ embeds: [
@@ -245,17 +220,7 @@ export = {
} }
if (subcommand === "sendverfiymessage") { if (subcommand === "sendverfiymessage") {
const channel2 = interaction.options.getChannel("channel")! const channel = interaction.options.getChannel("channel") as TextChannel
if (channel2.type !== ChannelType.GuildText) {
await interaction.reply({
content: "That channel is not a text channel.",
ephemeral: true,
})
return
}
const channel = channel2 as GuildTextBasedChannel
await channel.send({ await channel.send({
embeds: [ embeds: [
@@ -294,17 +259,7 @@ export = {
} }
if (subcommand === "sendwaitinglistmessage") { if (subcommand === "sendwaitinglistmessage") {
const channel2 = interaction.options.getChannel("channel")! const channel = interaction.options.getChannel("channel") as TextChannel
if (channel2.type !== ChannelType.GuildText) {
await interaction.reply({
content: "That channel is not a text channel.",
ephemeral: true,
})
return
}
const channel = channel2 as GuildTextBasedChannel
await channel.send({ await channel.send({
embeds: [ embeds: [

View File

@@ -2,7 +2,7 @@ import {
SlashCommandBuilder, SlashCommandBuilder,
PermissionFlagsBits, PermissionFlagsBits,
ChannelType, ChannelType,
GuildTextBasedChannel, TextChannel,
} from "discord.js" } from "discord.js"
import { color, devMessage } from "../../config/options.json" import { color, devMessage } from "../../config/options.json"
import { Command } from "../interfaces" import { Command } from "../interfaces"
@@ -27,7 +27,8 @@ export = {
.addChannelOption(option => .addChannelOption(option =>
option option
.setName("channel") .setName("channel")
.setDescription("The channel to set the slowmode of."), .setDescription("The channel to set the slowmode of.")
.addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement),
) )
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false), .setDMPermission(false),
@@ -36,32 +37,9 @@ export = {
await interaction.deferReply({ ephemeral: true }) await interaction.deferReply({ ephemeral: true })
const seconds = interaction.options.getInteger("seconds") ?? 5 const seconds = interaction.options.getInteger("seconds") ?? 5
const channel2 = const channel = (interaction.options.getChannel("channel") || interaction.channel) as TextChannel
interaction.options.getChannel("channel") ?? interaction.channel
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
if (channel2?.type !== ChannelType.GuildText) {
await interaction.editReply({
embeds: [
{
description:
"You can only set the slowmode of a text channel.",
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url:
interaction.guild!.iconURL({
forceStatic: false,
}) || undefined,
},
},
],
})
return
}
const channel = channel2 as GuildTextBasedChannel
if (seconds > 21600) { if (seconds > 21600) {
await channel.setRateLimitPerUser(21600) await channel.setRateLimitPerUser(21600)
await interaction.editReply({ await interaction.editReply({

View File

@@ -2,7 +2,7 @@ import {
ActionRowBuilder, ActionRowBuilder,
ButtonStyle, ButtonStyle,
ButtonBuilder, ButtonBuilder,
GuildTextBasedChannel, TextChannel,
} from "discord.js" } from "discord.js"
import { import {
color, color,
@@ -91,7 +91,7 @@ export = {
// update waiting list // update waiting list
const channel = guild.channels.cache.get( const channel = guild.channels.cache.get(
waitingListChannel, waitingListChannel,
) as GuildTextBasedChannel ) as TextChannel
const wlmessage = await channel!.messages.fetch(waitingListMessage) const wlmessage = await channel!.messages.fetch(waitingListMessage)
const wlembed = wlmessage.embeds[0] const wlembed = wlmessage.embeds[0]

View File

@@ -4,7 +4,7 @@ import {
ActionRowBuilder, ActionRowBuilder,
EmbedBuilder, EmbedBuilder,
GuildMember, GuildMember,
GuildTextBasedChannel, TextChannel,
} from "discord.js" } from "discord.js"
import { color } from "../../../config/options.json" import { color } from "../../../config/options.json"
import { largeM, smallM, ignM } from "../../../config/limitmessages.json" import { largeM, smallM, ignM } from "../../../config/limitmessages.json"
@@ -537,7 +537,7 @@ export = {
const channel = guild.channels.cache.get( const channel = guild.channels.cache.get(
applicationsChannel, applicationsChannel,
) as GuildTextBasedChannel ) as TextChannel
await channel.send({ await channel.send({
embeds: [ embeds: [
{ {

View File

@@ -4,7 +4,7 @@ import {
ButtonStyle, ButtonStyle,
EmbedBuilder, EmbedBuilder,
GuildMember, GuildMember,
GuildTextBasedChannel, TextChannel,
} from "discord.js" } from "discord.js"
import { import {
gm, gm,
@@ -305,7 +305,7 @@ module.exports = {
const appChannel = guild.channels.cache.get( const appChannel = guild.channels.cache.get(
inactivityLogChannel, inactivityLogChannel,
) as GuildTextBasedChannel ) as TextChannel
await appChannel.send({ await appChannel.send({
embeds: [ embeds: [

View File

@@ -4,7 +4,7 @@ import {
ActionRowBuilder, ActionRowBuilder,
EmbedBuilder, EmbedBuilder,
GuildMember, GuildMember,
GuildTextBasedChannel, TextChannel,
} from "discord.js" } from "discord.js"
import { color, staffApplicationsChannel } from "../../../config/options.json" import { color, staffApplicationsChannel } from "../../../config/options.json"
import { largeM, ignM } from "../../../config/limitmessages.json" import { largeM, ignM } from "../../../config/limitmessages.json"
@@ -464,7 +464,7 @@ export = {
const channel = guild.channels.cache.get( const channel = guild.channels.cache.get(
staffApplicationsChannel, staffApplicationsChannel,
) as GuildTextBasedChannel ) as TextChannel
await channel.send({ await channel.send({
embeds: [ embeds: [

View File

@@ -7,13 +7,13 @@ import {
import { getGuild, getIGN } from "../../utils/Hypixel" import { getGuild, getIGN } from "../../utils/Hypixel"
import { Cron, GuildData } from "../../interfaces" import { Cron, GuildData } from "../../interfaces"
import Illegitimate from "../../utils/Illegitimate" import Illegitimate from "../../utils/Illegitimate"
import { GuildTextBasedChannel } from "discord.js" import { TextChannel } from "discord.js"
const client = Illegitimate.client const client = Illegitimate.client
async function guildWeekly() { async function guildWeekly() {
const channel = client.channels.cache.get( const channel = client.channels.cache.get(
guildLogChannel, guildLogChannel,
) as GuildTextBasedChannel ) as TextChannel
if (!channel) { if (!channel) {
console.log("Guild log channel not found") console.log("Guild log channel not found")

View File

@@ -1,6 +1,7 @@
import { ChannelType, GuildMember, userMention } from "discord.js" import { GuildMember, userMention } from "discord.js"
import { color, botLogChannel } from "../../../../config/options.json" import { color } from "../../../../config/options.json"
import { Event } from "../../../interfaces" import { Event } from "../../../interfaces"
import logToChannel from "../../../utils/functions/logtochannel"
export = { export = {
name: "logNewJoins", name: "logNewJoins",
@@ -9,24 +10,9 @@ export = {
event: "guildMemberAdd", event: "guildMemberAdd",
execute(member: GuildMember) { execute(member: GuildMember) {
const channel = member.guild.channels.cache.get(botLogChannel)
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
if (!channel) { logToChannel("bot", {
console.log(
"[ERROR] Could not find channel used for new join logging.",
)
return
}
if (channel.type !== ChannelType.GuildText) {
console.log(
"[ERROR] The channel used for new join logging is not a text channel.",
)
return
}
channel.send({
embeds: [ embeds: [
{ {
title: "New Member", title: "New Member",

View File

@@ -1,7 +1,6 @@
import { onlineLogChannel, color } from "../../../../config/options.json" import logToChannel from "../../../utils/functions/logtochannel"
import { Event } from "../../../interfaces" import { Event } from "../../../interfaces"
import { ExtendedClient as Client } from "../../../utils/Client" import { color } from "../../../../config/options.json"
import { ChannelType } from "discord.js"
export = { export = {
name: "sendonlinemessage", name: "sendonlinemessage",
@@ -9,25 +8,12 @@ export = {
type: "event", type: "event",
event: "ready", event: "ready",
execute(client: Client) { execute() {
if (process.env.NODE_ENV === "dev") return if (process.env.NODE_ENV === "dev") return
const channel = client.channels.cache.get(onlineLogChannel)
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
if (!channel) { logToChannel("online", {
console.log(
"[ERROR] Could not find channel used for online message.",
)
return
}
if (channel.type !== ChannelType.GuildText) {
console.log("[ERROR] Online message channel is not a text channel.")
return
}
channel.send({
embeds: [ embeds: [
{ {
description: "Bot is online!", description: "Bot is online!",

View File

@@ -2,10 +2,10 @@ import {
userMention, userMention,
channelMention, channelMention,
VoiceState, VoiceState,
ChannelType,
} from "discord.js" } from "discord.js"
import { botLogChannel, color } from "../../../../config/options.json" import { color } from "../../../../config/options.json"
import { Event } from "../../../interfaces" import { Event } from "../../../interfaces"
import logToChannel from "../../../utils/functions/logtochannel"
export = { export = {
name: "vcJoinLeave", name: "vcJoinLeave",
@@ -16,29 +16,12 @@ export = {
execute(oldState: VoiceState, newState: VoiceState) { execute(oldState: VoiceState, newState: VoiceState) {
if (process.env.NODE_ENV === "dev") return if (process.env.NODE_ENV === "dev") return
const guild = oldState.guild
const channel = guild.channels.cache.get(botLogChannel)
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
if (!channel) {
console.log(
"[ERROR] Could not find channel used for voice channel join/leave logging.",
)
return
}
if (channel.type !== ChannelType.GuildText) {
console.log(
"[ERROR] The channel used for voice channel join/leave logging is not a text channel.",
)
return
}
const oldChannel = oldState.channel const oldChannel = oldState.channel
const newChannel = newState.channel const newChannel = newState.channel
if (oldChannel === null && newChannel !== null) { if (oldChannel === null && newChannel !== null) {
channel.send({ logToChannel("bot", {
embeds: [ embeds: [
{ {
title: "Voice Channel Join", title: "Voice Channel Join",
@@ -55,7 +38,7 @@ export = {
], ],
}) })
} else if (oldChannel !== null && newChannel === null) { } else if (oldChannel !== null && newChannel === null) {
channel.send({ logToChannel("bot", {
embeds: [ embeds: [
{ {
title: "Voice Channel Leave", title: "Voice Channel Leave",
@@ -74,7 +57,7 @@ export = {
} else if (oldChannel !== null && newChannel !== null) { } else if (oldChannel !== null && newChannel !== null) {
if (oldChannel.id === newChannel.id) return if (oldChannel.id === newChannel.id) return
channel.send({ logToChannel("bot", {
embeds: [ embeds: [
{ {
title: "Voice Channel Switch", title: "Voice Channel Switch",

View File

@@ -1,9 +1,10 @@
import { ExtendedClient as Client } from "../Client" import { ExtendedClient as Client } from "../Client"
import { errorLogChannel, color } from "../../../config/options.json" import { color } from "../../../config/options.json"
import { Autocomplete } from "../../interfaces" import { Autocomplete } from "../../interfaces"
import { Events, GuildTextBasedChannel } from "discord.js" import { Events } from "discord.js"
import path = require("path") import path = require("path")
import fs = require("fs") import fs = require("fs")
import logToChannel from "../functions/logtochannel"
type FileType = "js" | "ts" type FileType = "js" | "ts"
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
@@ -52,14 +53,8 @@ export default function loadAutocompleteEvents(client: Client, ft: FileType) {
await autocomplete.execute(interaction) await autocomplete.execute(interaction)
} catch (error) { } catch (error) {
if (process.env.NODE_ENV !== "dev") { if (process.env.NODE_ENV !== "dev") {
const channel = client.channels.cache.get(
errorLogChannel,
) as GuildTextBasedChannel
if (!channel) {
console.log("No error log channel found.")
}
await channel.send({ await logToChannel("error", {
embeds: [ embeds: [
{ {
title: "Autocomplete error occured", title: "Autocomplete error occured",

View File

@@ -1,9 +1,10 @@
import { ExtendedClient as Client } from "../Client" import { ExtendedClient as Client } from "../Client"
import { errorLogChannel, color } from "../../../config/options.json" import { color } from "../../../config/options.json"
import { Button } from "../../interfaces" import { Button } from "../../interfaces"
import { Events, GuildTextBasedChannel } from "discord.js" import { Events } from "discord.js"
import path = require("path") import path = require("path")
import fs = require("fs") import fs = require("fs")
import logToChannel from "../functions/logtochannel"
type FileType = "js" | "ts" type FileType = "js" | "ts"
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
@@ -40,14 +41,8 @@ export default function loadButtonEvents(client: Client, ft: FileType) {
await button.execute(interaction) await button.execute(interaction)
} catch (error) { } catch (error) {
if (process.env.NODE_ENV !== "dev") { if (process.env.NODE_ENV !== "dev") {
const channel = client.channels.cache.get(
errorLogChannel,
) as GuildTextBasedChannel
if (!channel) {
console.log("No error log channel found.")
}
await channel.send({ await logToChannel("error", {
embeds: [ embeds: [
{ {
title: "Button error occured", title: "Button error occured",

View File

@@ -1,9 +1,10 @@
import { ExtendedClient as Client } from "../Client" import { ExtendedClient as Client } from "../Client"
import { errorLogChannel, color } from "../../../config/options.json" import { color } from "../../../config/options.json"
import { Command } from "../../interfaces" import { Command } from "../../interfaces"
import { Events, GuildTextBasedChannel } from "discord.js" import { Events } from "discord.js"
import path = require("path") import path = require("path")
import fs = require("fs") import fs = require("fs")
import logToChannel from "../functions/logtochannel"
type FileType = "js" | "ts" type FileType = "js" | "ts"
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
@@ -41,14 +42,7 @@ export default function loadSlashCommandsEvents(client: Client, ft: FileType) {
await command.execute(interaction, client) await command.execute(interaction, client)
} catch (error) { } catch (error) {
if (process.env.NODE_ENV !== "dev") { if (process.env.NODE_ENV !== "dev") {
const channel = client.channels.cache.get( await logToChannel("error", {
errorLogChannel,
) as GuildTextBasedChannel
if (!channel) {
console.log("No error log channel found.")
}
await channel.send({
embeds: [ embeds: [
{ {
title: "Command error occured", title: "Command error occured",

View File

@@ -1,9 +1,10 @@
import { ExtendedClient as Client } from "../Client" import { ExtendedClient as Client } from "../Client"
import { ContextMenu } from "../../interfaces" import { ContextMenu } from "../../interfaces"
import { errorLogChannel, color } from "../../../config/options.json" import { color } from "../../../config/options.json"
import { Events, GuildTextBasedChannel } from "discord.js" import { Events } from "discord.js"
import path = require("path") import path = require("path")
import fs = require("fs") import fs = require("fs")
import logToChannel from "../functions/logtochannel"
type FileType = "js" | "ts" type FileType = "js" | "ts"
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
@@ -48,14 +49,7 @@ export default function loadContextMenuEvents(client: Client, ft: FileType) {
await command.execute(interaction) await command.execute(interaction)
} catch (error) { } catch (error) {
if (process.env.NODE_ENV !== "dev") { if (process.env.NODE_ENV !== "dev") {
const channel = client.channels.cache.get( await logToChannel("error", {
errorLogChannel,
) as GuildTextBasedChannel
if (!channel) {
console.log("No error log channel found.")
}
await channel.send({
embeds: [ embeds: [
{ {
title: "Contextmenu error occured", title: "Contextmenu error occured",

View File

@@ -1,9 +1,10 @@
import { ExtendedClient as Client } from "../Client" import { ExtendedClient as Client } from "../Client"
import { errorLogChannel, color } from "../../../config/options.json" import { color } from "../../../config/options.json"
import { Modal } from "../../interfaces" import { Modal } from "../../interfaces"
import { Events, GuildTextBasedChannel } from "discord.js" import { Events} from "discord.js"
import path = require("path") import path = require("path")
import fs = require("fs") import fs = require("fs")
import logToChannel from "../functions/logtochannel"
type FileType = "js" | "ts" type FileType = "js" | "ts"
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
@@ -42,14 +43,7 @@ export default function loadModalEvents(client: Client, ft: FileType) {
await modal.execute(interaction) await modal.execute(interaction)
} catch (error) { } catch (error) {
if (process.env.NODE_ENV !== "dev") { if (process.env.NODE_ENV !== "dev") {
const channel = client.channels.cache.get( await logToChannel("error", {
errorLogChannel,
) as GuildTextBasedChannel
if (!channel) {
console.log("No error log channel found.")
}
await channel.send({
embeds: [ embeds: [
{ {
title: "Button error occured", title: "Button error occured",

View File

@@ -0,0 +1,25 @@
import { guildid, onlineLogChannel, botLogChannel, guildLogChannel, errorLogChannel, moderationLogChannel } from "../../../config/options.json"
import { Guild, MessageCreateOptions, TextChannel } from "discord.js"
import Illegitimate from "../Illegitimate"
const channels = {
online: onlineLogChannel,
bot: botLogChannel,
guild: guildLogChannel,
error: errorLogChannel,
mod: moderationLogChannel
}
type Channel = keyof typeof channels
export default async function logToChannel(channel: Channel, message: MessageCreateOptions): Promise<void|null> {
const guild = Illegitimate.client.guilds.cache.get(guildid) as Guild
const logChannel = guild.channels.cache.get(channels[channel]) as TextChannel
if (!logChannel) {
console.log(`[ERROR] Could not find channel used for ${channel} logging.`)
return
}
await logChannel.send(message)
}