My Discord bot doesn't recognise members in a voice channel before the have switched to at least 1 other voice channel after the bot has started (after joining the channel, a user has to manually change to a different channel, then return, for the bot to recognise the member and be able to move them to the desired channel). This is a bit counterintuative, and defeats the purpose of my bot.
from discord.ext import commands
class Mute(commands.Cog):
# Commands
@commands.command()
async def mute(self, ctx):
vc = ctx.author.voice.channel
for member in vc.members:
await member.edit(mute=True)
await ctx.channel.purge()
@commands.command()
async def unmute(self, ctx):
vc = ctx.author.voice.channel
for member in vc.members:
await member.edit(mute=False)
await ctx.channel.purge()
@commands.command()
async def start(self, ctx):
vc = ctx.author.voice.channel
await ctx.channel.send("A new game has started!")
await ctx.channel.send("Users will now be moved. Game has started!")
await ctx.channel.purge()
channel = discord.utils.get(ctx.guild.channels, name="AU voice")
for member in vc.members:
await member.move_to(channel)
def setup(client):
client.add_cog(Mute(client))