循环命令(discord.py)

2024-04-16 04:03:11 发布

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

@bot.command(pass_context=True)
async def repeat(ctx):

    voice = get(bot.voice_clients, guild=ctx.guild)
    if not voice.is_playing:
            return await ctx.send('Aucune musique joué !')

    await ctx.send("La répétition est activé \n Si vous voulez désactivé : n#stop")

    voice.loop = True
    await ctx.message.add_reaction('✅')

为什么它没有无休止地重复我用play命令播放的音乐


Tags: sendtruegetasyncdefbotcontextpass
1条回答
网友
1楼 · 发布于 2024-04-16 04:03:11

嘿,你为什么不试试itertools呢。我不是一个真正的音乐机器人专家,所以我现在会使用ctx.send()

from itertools import cycle
import time
import discord
from discord.ext import commands, tasks

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

@commands.command()
async def repeat():
    music_list = cycle(["song1","song2"])
    while True:
        time.sleep("length of song")
        await ctx.send(next(music_list))

循环是一种非常好的循环方式,你应该尝试一下 这是一个循环如何工作的例子,也许这个图坦卡蒙会有所帮助:

https://www.youtube.com/watch?v=RK8RzuUMYt8

相关问题 更多 >