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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

嘗試在用戶說(shuō)出某些內(nèi)容時(shí)添加警告角色

嘗試在用戶說(shuō)出某些內(nèi)容時(shí)添加警告角色

牧羊人nacy 2023-08-08 16:53:04
Discord 試圖message.author在使用await message.author.add_roles(message.author,role,reason='Reason: Used \'%s\' in \'%s\ , on %s/%s/%s (day,month,year) at %s' % (word, str(message.channel),day,month,year,time))刪除第二個(gè)message.author修復(fù)此問(wèn)題時(shí)添加角色,因此應(yīng)該是:await message.author.add_roles(role,reason='Reason: Used \'%s\' in \'%s\ , on %s/%s/%s (day,month,year) at %s' % (word, str(message.channel),day,month,year,time))屬性錯(cuò)誤:Traceback (most recent call last):  File "C:\Users\Me\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\client.py", line 312, in _run_event    await coro(*args, **kwargs)  File "C:\Users\Me\Desktop\Productive\Programming Projects\Python 3\Other\MyBot\bot.py", line 41, in on_message    await bot.add_roles(message.author,role,reason='Reason: Used \'%s\' in \'%s\ , on %s/%s/%s (day,month,year) at %s' % (word, str(message.channel),day,month,year,time))AttributeError: 'Client' object has no attribute 'add_roles'名稱錯(cuò)誤:Ignoring exception in on_messageTraceback (most recent call last):  File "C:\Users\Me\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\client.py", line 312, in _run_event    await coro(*args, **kwargs)  File "C:\Users\Me\Desktop\Productive\Programming Projects\Python 3\Other\MyBot\bot.py", line 41, in on_message    await add_roles(message.author,role,reason='Reason: Used \'%s\' in \'%s\ , on %s/%s/%s (day,month,year) at %s' % (word, str(message.channel),day,month,year,time))NameError: name 'add_roles' is not defined所有相關(guān)代碼import discord;from discord.utils import getfrom datetime import datetimebot=discord.Client()@bot.eventasync def on_ready():    print('Logged in')    print('Username: %s' % (bot.user.name))    print('Userid: %s' % (bot.user.id))
查看完整描述

2 回答

?
月關(guān)寶盒

TA貢獻(xiàn)1772條經(jīng)驗(yàn) 獲得超5個(gè)贊

on_message中的Message對(duì)象應(yīng)包含 message.author 中的 Member 對(duì)象,因此您可以執(zhí)行以下操作:

await?message.author.add_roles(role,?reason='Reason:?Used?\'%s\'?in?\'%s\?,?on?%s/%s/%s?(day,month,year)?at?%s'?%?(word,?str(message.channel),day,month,year,time))


查看完整回答
反對(duì) 回復(fù) 2023-08-08
?
陪伴而非守候

TA貢獻(xiàn)1757條經(jīng)驗(yàn) 獲得超8個(gè)贊

過(guò)去,我是通過(guò)調(diào)用消息來(lái)完成此操作add_rolesauthor。在你的情況下,它會(huì)是這樣的:

await message.author.add_roles(role,reason='Reason: Used \'%s\' in \'%s\ , on %s/%s/%s (day,month,year) at %s' % (word, str(message.channel),day,month,year,time)

我認(rèn)為我沒(méi)有包含一個(gè)reason論點(diǎn),所以我不確定這種形式是否會(huì)采用該論點(diǎn),但如果其他形式這樣做,我認(rèn)為會(huì)的。


查看完整回答
反對(duì) 回復(fù) 2023-08-08
  • 2 回答
  • 0 關(guān)注
  • 165 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)