制作一个不和谐的机器人通过嵌入 discord.py 发送图像

Making a discord bot to send an image through an embed with discord.py

我尝试用 discord.py 制作一个 discord 机器人,当它看到命令“.pic”时会发送一张图片。当我 运行 程序并尝试 .pic 命令时,图片没有发送,嵌入也没有发送。我有一个可以冷却的小程序。我确实看到冷却功能有效,即使嵌入和图片不存在。我在控制台中也没有收到错误代码 这是我的代码:

import discord
import random
from discord.ext import commands

client = commands.Bot(command_prefix = ".")


@client.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.errors.CommandOnCooldown):  
        return await ctx.send('The command **{}** is still on cooldown for {:.2f}'.format(ctx.command.name, error.retry_after))

pictures =["https://i.imgur.com/LAmHP4K.jpg","https://i.imgur.com/sXS290O.jpg","https://i.imgur.com/Ar7Ihs5.jpg"]

@client.command()
@commands.cooldown(1, 2, commands.BucketType.user)  
async def pic(ctx):
  embed = discord.Embed(color = discord.colour.red())
  random_link = random.choice(pictures)
  embed.set_image(url = random_link)
  await ctx.send(embed = embed)

client.run("TOKEN")
 

discord.color是模块,discord.Color()是class。请记住,区分大小写在 python 中非常重要。你需要 discord.Color.red() 因为你需要 discord.Color class.

的红色方法