【发布时间】:2018-07-06 07:36:11
【问题描述】:
if message.content.lower().startswith('!kick') and (roleLFJob in message.author.roles or roleLFAba in message.author.roles):
await client.delete_message(message)
serverchannel = '405090256124248065'
messageParsed = message.content.split()
kick = messageParsed[0]
mention = messageParsed[1]
msg = messageParsed[2:]
for member in message.mentions:
await client.kick(member)
await client.send_message(discord.Object(id=serverchannel), '{0} was kicked by {1}, with reason:"**'.format(member.mention, message.author.mention) + msg + '**"')
当我不和谐地写这个命令时:
!kick @(member.mention) reason, reason and reason
出现此错误:
Ignoring exception in on_message Traceback (most recent call last):
File "C:\Users\senuk\AppData\Local\Programs\Python\Python35\lib\site-packages\discord\client.py", line 307, in _run_event
yield from getattr(self, event)(*args, **kwargs)
File "overmind.py", line 128, in on_message
await client.send_message(discord.Object(id=serverchannel), '{0} was kicked by {1} with reason:"**'.format(member.mention, message.author.mention) + msg + '**"')
TypeError: Can't convert 'list' object to str implicitly
【问题讨论】:
-
在格式字符串中使用 str(msg) 代替 msg
标签: python discord discord.py