Made voice clients per-server instead of using a single one.
This commit is contained in:
parent
4cf4da3633
commit
9889adbcbc
18
main.py
18
main.py
@ -57,8 +57,7 @@ async def ping(ctx: nextcord.Message):
|
|||||||
@client.command(description="Join the voice channel.")
|
@client.command(description="Join the voice channel.")
|
||||||
async def join(ctx: nextcord.Message):
|
async def join(ctx: nextcord.Message):
|
||||||
print("Joining")
|
print("Joining")
|
||||||
print(client.voice_clients)
|
if not ctx.guild.voice_client.channel:
|
||||||
if client.voice_clients.__len__() == 0:
|
|
||||||
if ctx.author.voice:
|
if ctx.author.voice:
|
||||||
global SquogCurrentConnection
|
global SquogCurrentConnection
|
||||||
SquogCurrentConnection = await ctx.author.voice.channel.connect()
|
SquogCurrentConnection = await ctx.author.voice.channel.connect()
|
||||||
@ -71,8 +70,8 @@ async def join(ctx: nextcord.Message):
|
|||||||
@client.command(description="Leaves the voice channel.")
|
@client.command(description="Leaves the voice channel.")
|
||||||
async def leave(ctx: nextcord.Message):
|
async def leave(ctx: nextcord.Message):
|
||||||
print("Leaving")
|
print("Leaving")
|
||||||
if client.voice_clients.__len__() != 0:
|
if ctx.guild.voice_client.is_connected():
|
||||||
await client.voice_clients[0].disconnect(force=True)
|
await ctx.guild.voice_client.disconnect(force=True)
|
||||||
await ctx.reply("Left.")
|
await ctx.reply("Left.")
|
||||||
else:
|
else:
|
||||||
await ctx.reply("Can't leave as i'm not in any voice channel.")
|
await ctx.reply("Can't leave as i'm not in any voice channel.")
|
||||||
@ -82,9 +81,9 @@ async def play(ctx: nextcord.Message, link):
|
|||||||
global SquogEvilFilename
|
global SquogEvilFilename
|
||||||
global SquogFinalName
|
global SquogFinalName
|
||||||
SquogEvilFilename = None
|
SquogEvilFilename = None
|
||||||
if client.voice_clients.__len__() == 0:
|
if not ctx.guild.voice_client.is_connected():
|
||||||
return await ctx.reply("I'm not in a voice channel.")
|
return await ctx.reply("I'm not in a voice channel.")
|
||||||
if client.voice_clients[0].is_playing():
|
if ctx.guild.voice_client.is_playing():
|
||||||
return await ctx.reply("I'm already playing music.")
|
return await ctx.reply("I'm already playing music.")
|
||||||
print(ctx.guild.voice_client.is_connected())
|
print(ctx.guild.voice_client.is_connected())
|
||||||
print(SquogCurrentConnection)
|
print(SquogCurrentConnection)
|
||||||
@ -103,9 +102,9 @@ async def play(ctx: nextcord.Message, link):
|
|||||||
|
|
||||||
@client.command(description="Stops the music in voice channel")
|
@client.command(description="Stops the music in voice channel")
|
||||||
async def stop(ctx: nextcord.Message):
|
async def stop(ctx: nextcord.Message):
|
||||||
if client.voice_clients.__len__() == 0:
|
if not ctx.guild.voice_client.is_connected():
|
||||||
return await ctx.reply("I'm not in a voice channel.")
|
return await ctx.reply("I'm not in a voice channel.")
|
||||||
if not SquogCurrentConnection.is_playing():
|
if not ctx.guild.voice_client.is_playing():
|
||||||
return await ctx.reply("I'm not playing music.")
|
return await ctx.reply("I'm not playing music.")
|
||||||
SquogCurrentConnection.stop()
|
SquogCurrentConnection.stop()
|
||||||
|
|
||||||
@ -119,7 +118,8 @@ async def stop(ctx: nextcord.Message):
|
|||||||
@client.event
|
@client.event
|
||||||
async def on_member_join(member: nextcord.Member):
|
async def on_member_join(member: nextcord.Member):
|
||||||
print(f"Member {member.display_name} joined")
|
print(f"Member {member.display_name} joined")
|
||||||
await member.add_roles(nextcord.utils.get(member.guild.roles, name="Squog"))
|
if member.guild.id == 1356433463854497944: # Only for the squog server
|
||||||
|
await member.add_roles(nextcord.utils.get(member.guild.roles, name="Squog"))
|
||||||
|
|
||||||
@client.event
|
@client.event
|
||||||
async def on_member_remove(member: nextcord.Member):
|
async def on_member_remove(member: nextcord.Member):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user