-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathOFWelcomeBot.py
189 lines (155 loc) · 6.32 KB
/
OFWelcomeBot.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
import discord
from discord.ext import commands
from datetime import datetime
intents = discord.Intents.all()
intents.members = True
bot = commands.Bot(command_prefix='!',intents=intents)
serverID = ""
with open('serverID.txt') as f:
serverID = f.readline()
serverID = int(serverID)
bot.newChanBitrate = 9600
bot.oldFartServer = ""
bot.twosMakerChannel = ""
bot.threesMakerChannel = ""
bot.fourssMakerChannel = ""
bot.sixesMakerChannel = ""
bot.twosCategory = ""
bot.threesCategory = ""
bot.foursCategory = ""
bot.sixesCategory = ""
bot.lfgCategory = ""
bot.customCreators = []
@bot.event
async def on_ready():
print(bot.user.name + " is Online...")
print(datetime.now().strftime('%H:%M:%S %m-%d-%Y'))
print('------')
#get guild
for g in bot.guilds:
if g.id == serverID:
print("Found server")
bot.oldFartServer = g
oldFartServer = bot.oldFartServer
#set the new channel bitrate to whatever the max rate is for the server
bot.newChanBitrate = int(oldFartServer.bitrate_limit)
#create categories
if not guild_has_category(oldFartServer, "2-MAX VOICE CHANNELS"):
print("making 2v2 category...")
await oldFartServer.create_category("2-MAX VOICE CHANNELS")
bot.twosCategory = get_category(oldFartServer, "2-MAX VOICE CHANNELS")
#create temp vc makers
await oldFartServer.create_voice_channel("➕ Create 2's VC",category=bot.twosCategory)
#create 3v3 category
if not guild_has_category(oldFartServer, "3-MAX VOICE CHANNELS"):
print("making 3v3 category...")
await oldFartServer.create_category("3-MAX VOICE CHANNELS")
bot.threesCategory = get_category(oldFartServer, "3-MAX VOICE CHANNELS")
#create temp vc makers
await oldFartServer.create_voice_channel("➕ Create 3's VC",category=bot.threesCategory)
#create 4v4 category
if not guild_has_category(oldFartServer, "4-MAX VOICE CHANNELS"):
print("making 4v4 category...")
await oldFartServer.create_category("4-MAX VOICE CHANNELS")
bot.foursCategory = get_category(oldFartServer, "4-MAX VOICE CHANNELS")
#create temp vc makers
await oldFartServer.create_voice_channel("➕ Create 4's VC",category=bot.foursCategory)
#create 6mans category
if not guild_has_category(oldFartServer, "6-MAX VOICE CHANNELS"):
print("making 6mans category...")
await oldFartServer.create_category("6-MAX VOICE CHANNELS")
bot.sixesCategory = get_category(oldFartServer, "6-MAX VOICE CHANNELS")
#create temp vc makers
await oldFartServer.create_voice_channel("➕ Create 6's VC",category=bot.sixesCategory)
#get categories
bot.twosCategory = get_category(oldFartServer, "2-MAX VOICE CHANNELS")
bot.threesCategory = get_category(oldFartServer, "3-MAX VOICE CHANNELS")
bot.foursCategory = get_category(oldFartServer, "4-MAX VOICE CHANNELS")
bot.sixesCategory = get_category(oldFartServer, "6-MAX VOICE CHANNELS")
#get creator channels
for c in oldFartServer.channels:
if c.name == "➕ Create 2's VC":
bot.twosMakerChannel = c
if c.name == "➕ Create 3's VC":
bot.threesMakerChannel = c
if c.name == "➕ Create 4's VC":
bot.foursMakerChannel = c
if c.name == "➕ Create 6's VC":
bot.sixesMakerChannel = c
async def update_channels():
print("update channels")
try:
await rename_and_reorder("2 Max", bot.twosMakerChannel.position +1)
except Exception as e:
print(e)
try:
await rename_and_reorder("3 Max", bot.threesMakerChannel.position +1)
except Exception as e:
print(e)
try:
await rename_and_reorder("4 Max", bot.foursMakerChannel.position +1)
except Exception as e:
print(e)
try:
await rename_and_reorder("6 Max", bot.sixesMakerChannel.position +1)
except Exception as e:
print(e)
@bot.event
async def on_voice_state_update(member, before, after):
#delete any empty VCs that we are making
if before.channel != None and "Max #" in before.channel.name:
if len(before.channel.members) == 0:
await before.channel.delete()
await update_channels()
if after.channel == bot.twosMakerChannel:
#create 2 max VC
cpos = bot.twosMakerChannel.position + 1
await create_custom_channel("2 Max", cpos, bot.twosCategory,2,member)
if after.channel == bot.threesMakerChannel:
#create 3 max VC
cpos = bot.threesMakerChannel.position + 1
await create_custom_channel("3 Max", cpos, bot.threesCategory,3,member)
if after.channel == bot.foursMakerChannel:
#create 4 max VC
cpos = bot.foursMakerChannel.position + 1
await create_custom_channel("4 Max", cpos, bot.foursCategory,4,member)
if after.channel == bot.sixesMakerChannel:
#create 6 max VC
cpos = bot.sixesMakerChannel.position + 1
await create_custom_channel("6 Max", cpos, bot.sixesCategory,6,member)
async def create_custom_channel(cName, position, category, userLimit, player):
cnum = 1
cpos = position
guild = bot.oldFartServer
for c in guild.channels:
if c != None and cName in c.name:
await c.edit(name = cName +" #" + str(cnum))
cnum = cnum+1
cpos = cpos +1
await guild.create_voice_channel(cName + " #" + str(cnum), position=cpos, category=category, bitrate = bot.newChanBitrate, user_limit=userLimit)
#pull user into new VC
for c in guild.channels:
if c != None and c.name == cName + " #" + str(cnum):
await player.move_to(c)
def guild_has_category(guild, cat):
for c in guild.categories:
if c.name == cat:
return True
print("didnt find it")
return False
def get_category(guild, cat):
for c in guild.categories:
if c.name == cat:
return c
return
async def rename_and_reorder(cName, cPos):
cnum = 1
#for channel in server
for c in bot.oldFartServer.channels:
if c != None and cName in c.name:
await c.edit(name = cName +" #" + str(cnum), position = cPos)
cnum = cnum +1
cPos = cPos +1
with open('token.txt') as f:
TOKEN = f.readline()
bot.run(TOKEN)