Python Discord.py彩虹嵌入

Python Discord.py彩虹嵌入,python,discord.py,Python,Discord.py,我正在创建一个彩虹嵌入命令,但我真的不知道它应该如何工作。也许你可以帮我创建命令:D 这是密码 @bot.commands() async def rainbowembed(ctx, *, message): embed = discordEmbed(description=message) ctx.send(embed=embed) for i in range(5): # On this point i dont know what to do...

我正在创建一个彩虹嵌入命令,但我真的不知道它应该如何工作。也许你可以帮我创建命令:D

这是密码

@bot.commands()
async def rainbowembed(ctx, *, message):
    embed = discordEmbed(description=message)
    ctx.send(embed=embed)
    for i in range(5):
        # On this point i dont know what to do...
        # I want to switch the color of the embed in this format
        # 0x3755ff, 0x13ff00, 0xff7400
        # and i want to repeat it 5 times, so it goes 5 times trough this Colors...

每0.1秒更改颜色的简单彩虹嵌入:

@client.command()
async def rainbow(ctx): 
    
    cols = [0x32a852, 0x3296a8, 0xb700ff, 0x9232a8, 0xa8326f, 0xf25207, 0x3efa00, 0xfa0000]
    embed = discord.Embed(
        title = "RAINBOW",
        color = random.choice(cols)
    )

    msg = await ctx.send(embed=embed)

    for i in range(1000):
        embed2 = discord.Embed(
            title = "RAINBOW",
            color = random.choice(cols)
        )
        await asyncio.sleep(0.1)
        await msg.edit(embed=embed2)

1000次后,嵌入不再改变颜色。

这是可能的,但请注意,如果过度使用,可能会导致API受限

导入模块:

import discord, asyncio
from discord.ext import commands
初始化客户端并分配
颜色
延迟

client = discord.ext.commands.Bot(command_prefix = "!")
colours = [0x3755ff, 0x13ff00, 0xff7400]
delay = 1
创建一个命令:

@client.command()
async def rainbowembed(ctx, *, message):
创建并发送嵌入文件:

    embed = discord.Embed(description=message)
    msg = await ctx.send(embed=embed)
每延迟
秒对每种颜色进行5次迭代编辑嵌入:

    for i in range(5):
        for colour in colours:
            await msg.edit(embed=discord.Embed(description=message, colour=colour))
            await asyncio.sleep(delay)
运行bot:

client.run("bot_token")
参考文献:


您是否收到任何错误消息?首先,在嵌入变量中,您还必须传递标题,这样它就不会是:
embed=discordEmbed(description=message)
而是:
embed=discordEmbed(title=title,description=message)
不必了,我不必做title=Ok,但是你有没有收到任何错误消息,或者只是没有做任何事情?你确定每秒编辑10次消息不会让你的API被禁止吗?我看到很多带有rainbow嵌入的机器人,我只听说只有rainbow角色,昵称是可禁用的。您将获得每0.1秒编辑消息的速率限制。可能此嵌入每0.1秒更改10次,然后有1秒的中断