因此,我决定尝试为我和我的朋友使用的频道制作一个不和谐的机器人,但是无论如何,我似乎都无法使该机器人加入我当前的语音频道。
我尝试赋予该机器人所有权限,并使用了不同的不和谐频道以及一个全新的频道,但我似乎无法使其加入当前的语音频道。我观看了在线教程以及阅读论坛帖子。我想让该漫游器稍后播放某些mp3文件,但我什至无法加入。
import discord
import json
import youtube_dl
from discord.ext import commands
from discord.voice_client import VoiceClient
from discord.ext.commands import Bot
client = commands.Bot(command_prefix = 'cb!')
filename = "respectspaid.json"
respects = 0
with open(filename) as f_obj:
respects = json.load(f_obj)
@client.event # event decorator/wrapper
async def on_ready():
print(f"We have logged in as {client.user}")
@client.event
async def on_message(message):
print(f"{message.channel}: {message.author}: {message.author.name}: {message.content}")
cajo_guild = client.get_guild(id)
if message.author == client.user:
return
if message.author.bot:
return
if "cb!membercount" == message.content.lower():
await message.channel.send(f"```py\n{cajo_guild.member_count}```")
elif "cb!hellothere" == message.content.lower():
await message.channel.send("General Kenobi!")
elif "F" == message.content:
global respects
respects += 1
await message.channel.send(f"```Respects paid: {respects}```")
elif "cb!disconnect" == message.content.lower():
with open(filename, 'w') as f_obj:
json.dump(respects, f_obj)
print("Dumping and closing client...")
await client.close()
sys.exit()
@client.command(pass_context=True)
async def join(ctx):
author = ctx.message.author
channel = author.voice_channel
await client.join_voice_channel(channel)
client.run(TOKEN)
就我所能测试的一切来看,一切正常,除了应该使该机器人加入频道的命令以外。