本文介紹了如何讓我的命令只禁止一個(gè)公會(huì)中的用戶的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
@commands.command(aliases=['hban'])
@commands.has_permissions(manage_messages=True)
@commands.cooldown(1,5,BucketType.user)
async def hackban(self, ctx, usid:int):
for guild in ctx.bot.guilds:
await guild.ban(discord.Object(id=usid))
embed = discord.Embed(title="<:Checkmark:837279790682734593> "+f"Successfully hack banned {usid}", color=discord.Color.dark_purple())
await ctx.send(embed=embed)
這個(gè)命令在它所在的所有公會(huì)中禁止用戶,我如何使它只禁止我使用該命令的公會(huì)中的用戶?
This command bans the user in all guilds it is in, how do I make it only ban the user in the guild I used the command in?
推薦答案
只需去掉for循環(huán),使用ctx.guild
作為公會(huì)
Simply remove the for-loop and use ctx.guild
as the guild
@commands.command(aliases=['hban'])
@commands.has_permissions(manage_messages=True)
@commands.cooldown(1,5,BucketType.user)
async def hackban(self, ctx, usid:int):
await ctx.guild.ban(discord.Object(id=usid))
embed = discord.Embed(title="<:Checkmark:837279790682734593> "+f"Successfully hack banned {usid}", color=discord.Color.dark_purple())
await ctx.send(embed=embed)
這篇關(guān)于如何讓我的命令只禁止一個(gè)公會(huì)中的用戶的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!