feat: remove legacy bot code

This commit is contained in:
TrèsAbhi committed 2024-07-21 19:41:37 -05:00
1 parent 9ffd20ffbf
commit 3f83fffade
28 files changed
+5 -589

No files matched your search

-15
View File
@@ -1,15 +0,0 @@
import { AttachmentBuilder, GuildMember, TextChannel } from 'discord.js';
import discord from '../../discord.json' assert { type: 'json' };
export default async function guildMemberAdd(member: GuildMember) {
if (member.guild.id === discord.sklld_guild_id) {
await (
member.guild.channels.cache.get(
discord.sklld_verify_channel,
) as TextChannel
).send({
content: `# Welcome, ${member.toString()}!\nPlease use the \`/link\` command like the video below to continue.`,
files: [new AttachmentBuilder('https://i.imgur.com/2p6GFgC.gif')],
});
}
}
@@ -16,11 +16,6 @@ import { translator } from '../../../core/localization/translator';
import { UserError } from '../../../hooks/userError';
import { Writeable } from '../../../types/writable';
const previewServers = [
'734786591205359697', // abhi
'460165161156870161', // optml
];
export default async function handleChatInputCommand(
interaction: ChatInputCommandInteraction<CacheType>,
) {
@@ -30,16 +25,6 @@ export default async function handleChatInputCommand(
await interaction.deferReply();
try {
if (
registry.inPreview &&
!previewServers.includes(`${interaction.guildId}`)
) {
const { t } = translator(interaction.locale);
interaction.editReply(t`bot.common.errors.preview`);
return;
}
const returnable = await registry.handler(interaction);
if (registry.handlesInteraction) return;
+4 -35
View File
@@ -8,13 +8,11 @@ import {
EmbedBuilder,
Interaction,
REST,
RESTPostAPIChatInputApplicationCommandsJSONBody,
Routes,
SlashCommandBuilder,
SlashCommandOptionsOnlyBuilder,
SlashCommandSubcommandsOnlyBuilder,
} from 'discord.js';
import discord from '../../../discord.json' assert { type: 'json' };
import { aboutCommand } from '../../commands/about';
import { breakdownCommand } from '../../commands/breakdown';
import { debugCommand } from '../../commands/debug';
@@ -58,10 +56,6 @@ export type InteractionReturnable =
| Promise<InteractionIterableReturnable>;
interface CommandRegistryBase {
inProduction: boolean;
inPublic: boolean;
inPreview?: boolean;
command:
| SlashCommandBuilder
| SlashCommandSubcommandsOnlyBuilder
@@ -124,38 +118,13 @@ export const commands = Promise.allSettled(COMMANDS_RAW).then((rawCommands) => {
});
const rest = new REST().setToken(secrets.DISCORD_TOKEN);
export const guildCommands: RESTPostAPIChatInputApplicationCommandsJSONBody[] =
[];
export const publicCommands: RESTPostAPIChatInputApplicationCommandsJSONBody[] =
[];
commands.then((awaitedCommands) => {
Object.values(awaitedCommands).forEach((registry) => {
const json = registry.command.toJSON();
const body = Object.values(awaitedCommands).map((registry) =>
registry.command.toJSON(),
);
if (registry.inPublic) {
publicCommands.push(json);
} else {
guildCommands.push(json);
}
});
try {
rest.put(Routes.applicationCommands(getClientId()), {
body: publicCommands,
});
(isDev()
? [discord.test_guild_id]
: [discord.tres_guild_id, discord.sklld_guild_id]
).forEach((guildId) =>
rest.put(Routes.applicationGuildCommands(getClientId(), guildId), {
body: guildCommands,
}),
);
} catch (error) {
console.error(error);
}
rest.put(Routes.applicationCommands(getClientId()), { body });
});
export default async function interactionCreate(