Discord.py Bot将文件发送到Discord Chann

2024-05-12 00:23:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图让我的不和谐机器人发送一个jpg文件到我的不和谐服务器,但我不断收到一个错误,似乎是相当罕见的,因为我找不到任何解决方案,在互联网上。。。

错误是。。。 discord.ext.commands.errors.CommandInvokeError:命令引发异常:ClientRequestError:无法为https://discordapp.com/api/v6/channels/454374995758678029/messages写入请求正文

我的进口货是

import time

import discord
from discord.ext import commands
from discord.ext.commands import Bot
import asyncio

我将提取出与错误相关的代码是

@bot.command(pass_context = True)

async def image(ctx):

        await bot.send_file(ctx.message.channel, open('halogen.jpg'))

我只是缺少导入,还是我的代码有问题?

谢谢你们


Tags: 文件代码fromimport服务器bot错误机器人