Привет. Я пытаюсь вернуть сообщение, когда пользователь использует команду !add
в каналах, отличных от каналов в проверке.Вот как я проверяю каналы, в которых должна использоваться команда:
@commands.check(lambda ctx: ctx.channel.id in [555913791615926302, 567769278351409174])
Вот как я пытаюсь это сделать, и у меня возникают проблемы с:
if not ctx.channel.id:
await ctx.send("You can only use this command in botroom.")
return
и вот как я буду использовать в коде:
@commands.command(pass_context=True)
@commands.check(lambda ctx: ctx.channel.id in [555913791615926302, 567769278351409174])
async def add(self, ctx, *, rolename):
author = ctx.message.author
role_dict = {
"members":557212810468392970,
"ps4":568761643916328960,
"lol":559792606364565505,
"pc":568725587322208287,
"nintendo switch":558649595102625795,
"ze/zir":569170061592494083}
if not ctx.channel.id:
await ctx.send("You can only use this command in botroom.")
return
role_id = role_dict.get(rolename.lower())
if not role_id:
message = 'I cannot find the role **{}**.'
embed = discord.Embed(description=message.format(rolename))
await ctx.send(embed=embed)
return
role = discord.utils.get(ctx.message.guild.roles, id = role_id)
if role in author.roles:
message = 'It looks like you already have the role **{}**.'
embed = discord.Embed(description=message.format(role.name))
await ctx.send(embed=embed)
else:
await author.add_roles(role)
message = '{} added the role **{}**.'.format(author.display_name, role.name)
embed = discord.Embed(description=message.format(author.display_name, role.name), colour=0x56e011)
await ctx.send(embed=embed)