好的,所以我正在用 Python 设计一个 Discord 机器人,虽然我很新。我试图让它加入语音频道,所以我做了一些研究并提出了以下建议,我删掉了机器人的不相关部分,所以这只是语音连接的部分。它说:在应该设置前缀的行上未定义名称“命令”:
private val viewModel : UserProfileViewModel by viewModels {
VMF(userRepository, arguments)
}
答案 0 :(得分:1)
您必须使用 from discord.ext import commands
import discord
import os
import requests
import json
import random
from discord.ext import commands
bot = commands.Bot(command_prefix='!')
@bot.event
async def on_ready():
print("Eingeloggt als {0.user}".format(client))
@bot.command()
async def join(ctx):
channel = ctx.author.voice.channel
await channel.connect()
@bot.command()
async def leave(ctx):
await ctx.voice_client.disconnect()
bot.run(os.getenv("TOKEN"))