我为我的音乐机器人做了这段代码,但当机器人不在语音通道时,机器人如何检查,机器人会自动连接回特定的通道,如id。但是,当机器人在另一个语音通道中使用时,机器人不会返回到我制作的特定语音通道。idk如何编码间隔,循环,或检查机器人是否在语音中。 client.on("ready", () => {
console.log(`Hello ${client.user.username} is now online!`);
let channel = client.channels.cache.get("720137811587629119");
我做了一个音乐不和谐的机器人,我想检查用户是否在同一个声音频道与机器人。
我试过以下几种方法,但都没有用:
let voiceBot = client.voice.connections.channel;
const voiceChannel = msg.member.voice.channel;
if(!voiceBot == voiceChannel)
return msg.channel.send('you need to be in the same channel as the bot!')
我开始用discord.py做一个不和谐的音乐机器人了。我已经学会了如何在用户编写命令dj/play时将机器人连接到语音通道。但是,我希望机器人加入用户编写命令所在的语音通道。有没有办法做到这一点? 下面是我的代码: #imports
import discord
from discord.ext import commands
from random import randint
import aiohttp
from youtube_dl import YoutubeDL
import os
# dotenv.load_dotenv()
#setup
audio_downloder
我正在做一个机器人,它可以在语音通道中播放东西,但问题是代码认为im在语音通道中,但我不是。我使用下面的代码来检查它 const voice_channel = message.member.voice.channel;
if (!voice_channel) {return sendMessage('**Error**', '#FF0000', 'You need to be in voice
channel to use this command.', message, Discord);} 我没有得到任何错误。谢谢你的帮助。
@client.event
async def on_voice_state_update(member, before, after):
# This function is called when not only member join to the voice channel,
# but also member changed their status to mute.
# So, it is necessary to catch only events that joining channel.
if before.channel != after.