【发布时间】:2022-01-23 23:45:11
【问题描述】:
import discord
from discord.ext import commands
client = discord.Client()
bot = commands.Bot(command_prefix="!")
@client.event
async def on_ready():
print("I'm logged in as {0.user}.".format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith("!test"):
await message.channel.send("Test passed successfully!")
@commands.command()
async def join(self,ctx):
if ctx.author.voice is None:
await ctx.send("You are not in a voice channel")
voice_channel = client.get_channel(ctx.author.voice.channel.id)
if ctx.voice_client is None:
await voice_channel.connect()
else:
await ctx.voice_client.move_to(voice_channel)
await ctx.send("idk")
@commands.command()
async def disconnect(self,ctx):
await ctx.voice_client.disconnect()
机器人不加入我不知道我做错了什么。它应该只加入我的语音频道。我看了this 教程,但正如我所说,它没有用。
【问题讨论】:
标签: python discord discord.py