python - Python:我不确定为什么我的不和谐机器人代码会出现此错误
问题描述
我正在尝试使用 mega.py 制作一个不和谐的机器人,它将在 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 的不和谐 API async def on_message
,则接受一个输入,即消息。在这一行:
song = discord.Message.content
当你真的应该做的时候,你将歌曲设置为与不和谐库相关的东西:
song = find.content
这是一个字符串。
推荐阅读
- c# - 如何安全地处理从单例返回的客户端实例?
- discord.js - TypeError [ERR_INVALID_ARG_TYPE]:“url”参数必须是字符串类型
- sql - 如何选择在 postgresql 中更新其值的列的列名?
- amazon-web-services - 即使先前关联的 CloudFront 分配已被销毁,也无法删除 Lambda@Edge
- python - 运行外部 python 命令
- php - Twilio:SSL 证书问题:无法获取本地颁发者证书
- prolog - 序言。构造图的传递闭包
- python - 复杂的列表列到列字符串匹配并派生另一列
- javascript - 匹配交易总额的最简单方法?
- python - SQL - 通过循环执行设置值