diff --git a/src/commands/setup.ts b/src/commands/setup.ts index a029957..147fb68 100644 --- a/src/commands/setup.ts +++ b/src/commands/setup.ts @@ -159,8 +159,19 @@ const execute = async (bot: Bot, interaction: Interaction) => { The Discord Slash Command system will ensure you provide all the required details.`, }); + + // Set permissions for self, skip if we already failed to set roles + !logChannelErrorOut && await bot.helpers.editChannelPermissionOverrides(logChannelId, { + id: botId, + type: OverwriteTypes.Member, + allow: ['SEND_MESSAGES', 'VIEW_CHANNEL', 'EMBED_LINKS'], + }).catch((e: Error) => { + utils.commonLoggers.channelUpdateError('setup.ts', 'self-allow', e); + mgrRoleErrorOut = true; + }); + // Test sending a message to the logChannel - await bot.helpers.sendMessage(logChannelId, { + !logChannelErrorOut && await bot.helpers.sendMessage(logChannelId, { embeds: [{ title: `This is the channel ${config.name} will be logging events to.`, description: `${config.name} will only send messages here as frequently as your event managers update events.`, @@ -183,7 +194,7 @@ The Discord Slash Command system will ensure you provide all the required detail fields: [ { name: `Please allow ${config.name} to send messages in the requested channel.`, - value: `${config.name}`, + value: `<#${logChannelId}>`, }, ], }], @@ -213,6 +224,16 @@ The Discord Slash Command system will ensure you provide all the required detail mgrRoleErrorOut = true; }); + // Set permissions for self, skip if we already failed to set roles + !mgrRoleErrorOut && await bot.helpers.editChannelPermissionOverrides(interaction.channelId, { + id: botId, + type: OverwriteTypes.Member, + allow: ['SEND_MESSAGES', 'VIEW_CHANNEL', 'EMBED_LINKS'], + }).catch((e: Error) => { + utils.commonLoggers.channelUpdateError('setup.ts', 'self-allow', e); + mgrRoleErrorOut = true; + }); + if (mgrRoleErrorOut) { // Cannot update role overrides on channel, error out bot.helpers.sendInteractionResponse(interaction.id, interaction.token, {