A powerful and extendable Discord bot, with it's own module system :3 thevoid.cafe/projects/voidy
at develop 36 lines 1.3 kB view raw
1import { ChannelType, MessageFlags, PermissionFlagsBits, SlashCommandSubcommandBuilder } from "discord.js"; 2import { Command, requirePermission } from "@voidy/framework"; 3import { GuildConfig, type IGuildConfig } from "../../schemas/GuildConfig"; 4 5export default new Command({ 6 id: "guild.welcome.set-channel", 7 use: [requirePermission(PermissionFlagsBits.ManageGuild)], 8 data: new SlashCommandSubcommandBuilder() 9 .setName("set-channel") 10 .setDescription("Set the welcome message channel.") 11 .addChannelOption((option) => 12 option 13 .setName("channel") 14 .setDescription("Channel for welcome messages.") 15 .addChannelTypes(ChannelType.GuildText) 16 .setRequired(true), 17 ), 18 19 execute: async ({ interaction, client }) => { 20 const channel = interaction.options.getChannel("channel", true); 21 22 const doc = await GuildConfig.findOneAndUpdate( 23 { guildId: interaction.guildId }, 24 { $set: { "welcome.channelId": channel.id } }, 25 { upsert: true, new: true }, 26 ); 27 28 const cache = client.data.get("guildConfig") as Map<string, IGuildConfig> | undefined; 29 if (cache && interaction.guildId) cache.set(interaction.guildId, doc.toObject()); 30 31 await interaction.reply({ 32 content: `Welcome channel set to <#${channel.id}>.`, 33 flags: [MessageFlags.Ephemeral], 34 }); 35 }, 36});