Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Commit

Permalink
Make sure the bot can send messages before setting the channel.
Browse files Browse the repository at this point in the history
  • Loading branch information
DevCytech committed Mar 2, 2021
1 parent 1f12d1e commit 14beb80
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/commands/moderation/set-farewell.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,27 @@ module.exports.run = async ({ message, args, guildData }) => {
);
}

// Check permissions
console.log(
channel.permissionsFor(message.guild.me).has('SEND_MESSAGES'),
);
if (
!channel.permissionsFor(message.guild.me).has('SEND_MESSAGES')
) {
return message.channel.send(
improperUsage(
'I am unable to send messages in that channel.',
),
);
}
if (!channel.permissionsFor(message.guild.me).has('ATTACH_FILES')) {
return message.channel.send(
improperUsage(
'I am unable to send images *(or files)* in that channel.',
),
);
}

guildData.farewellChannel = channel.id;
await guildData.save();
return message.channel.send(
Expand Down
18 changes: 18 additions & 0 deletions src/commands/moderation/set-welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,24 @@ module.exports.run = async ({ message, args, guildData }) => {
);
}

// Check permissions
if (
!channel.permissionsFor(message.guild.me).has('SEND_MESSAGES')
) {
return message.channel.send(
improperUsage(
'I am unable to send messages in that channel.',
),
);
}
if (!channel.permissionsFor(message.guild.me).has('ATTACH_FILES')) {
return message.channel.send(
improperUsage(
'I am unable to send images *(or files)* in that channel.',
),
);
}

guildData.welcomingChannel = channel.id;
await guildData.save();
return message.channel.send(
Expand Down

0 comments on commit 14beb80

Please sign in to comment.