diff --git a/src/commands/mod-application.js b/src/commands/mod-application.js index ba81b69..4d13a95 100644 --- a/src/commands/mod-application.js +++ b/src/commands/mod-application.js @@ -7,6 +7,8 @@ const { modal: modApplicationModal } = require('../modals/mod-application'); * @param {Discord.CommandInteraction} interaction */ async function modApplicationHandler(interaction) { + modApplicationModal.setCustomId("mod-application-" + interaction.options.get('role').value); + interaction.showModal(modApplicationModal, { client: interaction.client, interaction: interaction @@ -16,11 +18,22 @@ async function modApplicationHandler(interaction) { const command = new SlashCommandBuilder() .setDefaultMemberPermissions(Discord.PermissionFlagsBits.SendMessages) .setName('mod-application') - .setDescription('Apply for a position as a moderator'); + .setDescription('Apply for a position as a moderator.') + .addStringOption(option => + option.setName('role') + .setDescription('Moderator type to apply to.') + .setRequired(true) + .addChoices( + { name: 'Discord Moderator', value: 'discord' }, + { name: 'Discord VC Moderator', value: 'vc' } + //{ name: 'Forum Moderator', value: 'forum' }, + //{ name: 'Network Moderator', value: 'network' }, + //{ name: 'Juxtaposition Moderator', value: 'juxt' } + )); module.exports = { name: command.name, - help: 'Displays a popup modal to apply for a moderator position.\n```\nUsage: /mod-application\n```', + help: 'Displays a popup modal to apply for a moderator position.\n```\nUsage: /mod-application role\n```', handler: modApplicationHandler, deploy: command.toJSON() }; \ No newline at end of file diff --git a/src/commands/settings.js b/src/commands/settings.js index 25086e0..64e1d11 100644 --- a/src/commands/settings.js +++ b/src/commands/settings.js @@ -8,6 +8,10 @@ const editableOptions = [ 'unverified_role_id', 'developer_role_id', 'mod_applications_channel_id', + 'vc_mod_apps_channel_id', + 'forum_mod_apps_channel_id', + 'network_mod_apps_channel_id', + 'juxt_mod_apps_channel_id', 'reports_channel_id', 'readme_channel_id', 'rules_channel_id', diff --git a/src/database.js b/src/database.js index 4411300..1f16b87 100644 --- a/src/database.js +++ b/src/database.js @@ -23,6 +23,10 @@ async function connect() { unverified_role_id TEXT, developer_role_id TEXT, mod_applications_channel_id TEXT, + vc_mod_apps_channel_id TEXT, + forum_mod_apps_channel_id TEXT, + network_mod_apps_channel_id TEXT, + juxt_mod_apps_channel_id TEXT, reports_channel_id TEXT, readme_channel_id TEXT, rules_channel_id TEXT, @@ -34,15 +38,47 @@ async function connect() { UNIQUE(guild_id) )`); - // This adds an ay_lmao_disabled column to the server settings table, if missing. + // This adds items to the server settings table, if missing. let hasAyLmaoColumn = false; + let hasVCModApps = false; + let hasForumModApps = false; + let hasNetworkModApps = false; + let hasJuxtModApps = false; await database.each('SELECT * FROM pragma_table_info(\'server_settings\')', (_err, row) => { - if (row.name === 'ay_lmao_disabled') hasAyLmaoColumn = true; + switch(row.name) { + case 'ay_lmao_disabled': + hasAyLmaoColumn = true; + break; + case 'vc_mod_apps_channel_id': + hasVCModApps = true; + break; + case 'forum_mod_apps_channel_id': + hasForumModApps = true; + break; + case 'network_mod_apps_channel_id': + hasNetworkModApps = true; + break; + case 'juxt_mod_apps_channel_id': + hasJuxtModApps = true; + break; + } }); if (!hasAyLmaoColumn) { await database.run('ALTER TABLE server_settings ADD ay_lmao_disabled INTEGER DEFAULT 0 NOT NULL;'); } + if (!hasVCModApps) { + await database.run('ALTER TABLE server_settings ADD vc_mod_apps_channel_id TEXT;'); + } + if (!hasForumModApps) { + await database.run('ALTER TABLE server_settings ADD forum_mod_apps_channel_id TEXT;'); + } + if (!hasNetworkModApps) { + await database.run('ALTER TABLE server_settings ADD network_mod_apps_channel_id TEXT;'); + } + if (!hasJuxtModApps) { + await database.run('ALTER TABLE server_settings ADD juxt_mod_apps_channel_id TEXT;'); + } await database.run(`CREATE TABLE IF NOT EXISTS nlp_disabled ( guild_id TEXT, diff --git a/src/modals/mod-application.js b/src/modals/mod-application.js index e746da4..4fbb888 100644 --- a/src/modals/mod-application.js +++ b/src/modals/mod-application.js @@ -63,6 +63,7 @@ async function modApplicationHandler(interaction) { ephemeral: true }); + const modType = interaction.customId.split('-').pop(); const experience = interaction.fields.getTextInputValue('experience'); const timezone = interaction.fields.getTextInputValue('timezone'); const availablity = interaction.fields.getTextInputValue('availablity'); @@ -72,7 +73,26 @@ async function modApplicationHandler(interaction) { const applyingMember = await interaction.member.fetch(); const guild = await interaction.guild.fetch(); - const channelId = await database.getGuildSetting(interaction.guildId, 'mod_applications_channel_id'); + var selectedDBItem = ''; + switch(modType) { + case 'discord': + selectedDBItem = 'mod_applications_channel_id'; + break; + case 'vc': + selectedDBItem = 'vc_mod_apps_channel_id'; + break; + case 'forum': + selectedDBItem = 'forum_mod_apps_channel_id'; + break; + case 'network': + selectedDBItem = 'network_mod_apps_channel_id'; + break; + case 'juxt': + selectedDBItem = 'juxt_mod_apps_channel_id'; + break; + } + + const channelId = await database.getGuildSetting(interaction.guildId, selectedDBItem); const channel = channelId && await guild.channels.fetch(channelId); if (!channel) { @@ -82,8 +102,25 @@ async function modApplicationHandler(interaction) { const modApplicationEmbed = new Discord.EmbedBuilder(); modApplicationEmbed.setColor(0x9D6FF3); - modApplicationEmbed.setTitle('Mod Application'); - modApplicationEmbed.setDescription(`<@${applyingMember.user.id}> has submitted a moderator application`); + + switch(modType) { + case 'discord': + modApplicationEmbed.setTitle('Discord Mod Application'); + break; + case 'vc': + modApplicationEmbed.setTitle('VC Mod Application'); + break; + case 'forum': + modApplicationEmbed.setTitle('Forum Mod Application'); + break; + case 'network': + modApplicationEmbed.setTitle('Network Mod Application'); + break; + case 'juxt': + modApplicationEmbed.setTitle('Juxt Mod Application'); + break; + } + modApplicationEmbed.setDescription(`<@${applyingMember.user.id}> has submitted a ${modType} moderator application`); modApplicationEmbed.setImage('attachment://pending-banner.png'); modApplicationEmbed.setThumbnail('attachment://pending-icon.png'); modApplicationEmbed.setAuthor({