第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用audit_log條目取消禁止不在特定服務器上工作的目標用戶-discord.py

使用audit_log條目取消禁止不在特定服務器上工作的目標用戶-discord.py

繁花不似錦 2023-07-11 14:32:48
@bot.command()async def unban(ctx, id: int):    user = await bot.fetch_user(id)    async for entry in ctx.message.guild.audit_logs(limit=None, user=user, action=discord.AuditLogAction.ban):        await ctx.guild.unban(entry.target)        print("Unbanned ", entry.target, entry.target.id, "Banned by ", entry.user, "Entry ID: ", entry.id)編寫上面的函數是為了獲取用戶 ID,并將其傳遞給audit_logs() 以獲取該用戶禁令的所有審核日志條目。然后我嘗試使用入口目標發(fā)出 unban() 。當我在我的私人服務器上測試它時,這是有效的。我邀請了一堆機器人,自己禁止了一些機器人,然后用一個機器人禁止了其他機器人。我使用自己的用戶 ID 運行該命令,BattleNubBot 僅取消了我已禁止的用戶。我認為我修改的服務器的管理員可以邀請我的機器人查看審核日志并禁止權限,然后我們在那里嘗試了該命令。我們得到:忽略命令 unban 中的異常:Traceback (most recent call last):  File "C:\Users\Joey\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped    ret = await coro(*args, **kwargs)  File ".\BattleNubBot.py", line 21, in unban    await ctx.guild.unban(entry.target)  File "C:\Users\Joey\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\guild.py", line 1892, in unban    await self._state.http.unban(user.id, self.id, reason=reason)  File "C:\Users\Joey\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\http.py", line 243, in request    raise NotFound(r, data)discord.errors.NotFound: 404 Not Found (error code: 10026): Unknown Ban
查看完整描述

1 回答

?
楊__羊羊

TA貢獻1943條經驗 獲得超7個贊

我不知道為什么要audit_logs取消會員封禁,有更好的方法嗎


@client.command()

async def unban(ctx, member):

    banned_users = await ctx.guild.bans()

    member_name, member_discriminator = member.split("#")

    for banned_member in banned_users:

        user = banned_member.user

        if (user.name, user.discriminator) == (member_name, member_discriminator):

            await ctx.guild.unban(user)

如果您只想執(zhí)行取消禁止命令,這將起作用。你可以像這樣使用它.unban someone#1234。


查看完整回答
反對 回復 2023-07-11
  • 1 回答
  • 0 關注
  • 114 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號