![](/img/trans.png)
[英]I'm trying to write a discord bot in python but my code is not working
[英]Python: I'm not sure why my discord bot code is giving this error
我正在尝试使用 mega.py 制作一个 discord 机器人,它将在 mega.nz 上搜索您的文件,但给了我一些错误,我不知道这意味着什么。 该命令将是 >find(无论您想在 MEGA 存档中获取什么,在我的情况下是 mp3 文件),并且我希望机器人将 MEGA 链接发送到 Discord 频道中请求的文件。 这是我在 python 的第一个项目,我希望我能克服这个错误。
这是错误。
TypeError: unsupported operand type(s) for +: 'member_descriptor' and 'str'
这是当前的代码。
import discord
from discord.ext import commands
from mega import Mega
client = commands.Bot(command_prefix=">")
@client.event
async def on_ready():
await client.change_presence(status=discord.Status.dnd)
print('it worked?')
@client.event
async def on_message(find):
mega = Mega()
song = discord.Message.content
m = mega.login("email", "password")
file = m.find(song + '.mp3')
link = m.get_link(file)
if file:
await ctx.send(link)
client.run('token')
如果我理解 python 的 discord API 正确async def on_message
,则接受输入即消息。 在这一行:
song = discord.Message.content
您将歌曲设置为与 discord 库相关的内容,而您确实应该这样做:
song = find.content
这是一个字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.