I am building a public discord.py bot and I want that I can use every feature even if I don't have the rights on that server like:
I am on a server and they're using my bot but I have no rights but I still could use clear or anything I am sorry if this question could be easily answered on the docs but the best I found was this:
@commands.bot_has_role(11132312313213)
my code looks like this:
@bot.command()
async def clear(ctx, amount=11):
if (not ctx.author.guild_permissions.manage_messages):
await ctx.send('Du hast keine ``Rechte`` für diesen Command! Wende dich bitte an einen Supporter :)')
return
amount = amount 1
if amount > 101:
await ctx.send('Sorry Bre nur 100 Nachrichten werden hier gelöscht')
else:
await ctx.channel.purge(limit=amount)
await ctx.send('Cleared!', delete_after=3)
too lazy to read: Permissions for User ID
I tried to look into the Docs, searched it on google and youtube.
CodePudding user response:
you can make a if query, where the permissions and the useris is checked.
your code would like this:
@bot.command()
async def clear(ctx, amount=11):
userid = YOUR_USERID_AS_INTEGER
if not (ctx.author.guild_permissions.manage_messages or ctx.author.id == userid):
await ctx.send('Du hast keine ``Rechte`` für diesen Command! Wende dich bitte an einen Supporter :)')
return
amount = amount 1
if amount > 101:
await ctx.send('Sorry Bre nur 100 Nachrichten werden hier gelöscht')
else:
await ctx.channel.purge(limit=amount)
await ctx.send('Cleared!', delete_after=3)
the variable userid
would be your userid as integer (e.g.: 204050461957941234)