python - discord.ext.commands.errors.CommandNotFound:找不到命令“播放”错误
问题描述
我正在尝试为不和谐创建一个音乐机器人,我完成了代码并尝试运行它,当我运行播放命令时它只是这么说。
Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "play" is not found
这是我的代码。
import discord
from discord.ext import commands
import youtube_dl
TOKEN = "Token here"
bot = discord.ext.commands.Bot(command_prefix = "s ");
@bot.event
async def on_ready():
channel = discord.utils.get(bot.get_all_channels(), id=794444804607574026)
await channel.connect()
async def play(ctx, url):
player = await voice_client.create_ytdl_player(url)
player.start()
bot.run(TOKEN)
解决方案
你上面还没有添加@bot.command(name="play")
播放功能
import discord
from discord.ext import commands
import youtube_dl
TOKEN = "Token here"
bot = discord.ext.commands.Bot(command_prefix = "s ");
@bot.event
async def on_ready():
channel = discord.utils.get(bot.get_all_channels(), id=794444804607574026)
await channel.connect()
@bot.command(name="play")
async def play(ctx, url):
player = await voice_client.create_ytdl_player(url)
player.start()
bot.run(TOKEN)
推荐阅读
- java - 无法实例化 android 驱动程序 appium 1.8.1
- sql - 无法更新列的格式化值
- html - 输入框搜索输入键
- python - Tkinter:滚动条显示但不起作用
- python-3.x - 在 seaborn catplot 中指定颜色
- c# - 为什么我的 Asp.Net 控制器中的 IFormFile 没有发生模型绑定?
- python - 如何更新复杂 Python 字典中的键名
- machine-learning - 为多输入 Keras 模型设计数据生成器的正确方法是什么?
- database - MongoDB 如何使 2 个嵌套文档具有相同的 _id?
- c - 尝试使用 sendto() 发送消息时出错