suppress error message in togglechannel if DMs blocked by user
@@ -189,6 +189,7 @@ class Extras:
"""Enable or disable access to specific channels."""
author = ctx.message.author
await self.bot.delete_message(ctx.message)
+ try:
if channelname == "elsewhere":
if self.bot.elsewhere_role in author.roles:
await self.bot.remove_roles(author, self.bot.elsewhere_role)
@@ -200,6 +201,8 @@ class Extras:
await self.bot.send_message(author, "Your access to elsewhere is restricted, contact staff to remove it.")
else:
await self.bot.send_message(author, "{} is not a valid toggleable channel.".format(channelname))
+ except discord.errors.Forbidden:
+ pass
@commands.command(pass_context=True)
async def rainbow(self, ctx):
