-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlobby_text.py
67 lines (47 loc) · 2.34 KB
/
lobby_text.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import settings
import discord
from discord.ext import commands
class lobbytext(commands.Cog):
client = commands.Bot(command_prefix='.')
def __init__(self, client):
self.client = client
print("Loading Lobby Text...")
@commands.Cog.listener()
async def on_voice_state_update(self, member, before, after):
role1 = discord.utils.get(member.guild.roles, id=settings.lobby_one_role_id)
role2 = discord.utils.get(member.guild.roles, id=settings.lobby_two_role_id)
lobby1text = discord.utils.get(member.guild.text_channels, id=settings.lobby_one_text_id)
lobby2text = discord.utils.get(member.guild.text_channels, id=settings.lobby_two_text_id)
lobby1voice = discord.utils.get(member.guild.voice_channels, id=settings.lobby_one_vc_id)
lobby2voice = discord.utils.get(member.guild.voice_channels, id=settings.lobby_two_vc_id)
hidden_group = discord.utils.get(member.guild.categories, id=settings.hidden_chat_id)
main_group = discord.utils.get(member.guild.categories, id=settings.main_cat_id)
if after.channel is None:
pass # user DC'd
if after.channel == lobby2voice:
await member.remove_roles(role1)
await member.add_roles(role2)
if after.channel == lobby1voice:
await member.remove_roles(role2)
await member.add_roles(role1)
if after.channel != lobby1voice and after.channel != lobby2voice:
await member.remove_roles(role1)
await member.remove_roles(role2)
if lobby1voice.members and lobby2voice.members:
await lobby1text.edit(category=main_group, position=6)
await lobby2text.edit(category=main_group, position=6)
return
if lobby2voice.members:
await lobby2text.edit(category=main_group, position=7)
await lobby1text.edit(category=hidden_group, position=1)
return
if lobby1voice.members:
await lobby1text.edit(category=main_group, position=6)
await lobby2text.edit(category=hidden_group, position=2)
return
await lobby1text.edit(category=hidden_group, position=1)
await lobby2text.edit(category=hidden_group, position=2)
def setup(client):
client.add_cog(lobbytext(client))