-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
264 lines (211 loc) · 9.81 KB
/
bot.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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
# bot.py
import os
import time
import random
import discord
import re
from discord.ext import commands
from discord.ext.commands import Bot
from dotenv import load_dotenv
#Bot invite link: https://discord.com/api/oauth2/authorize?client_id=782816994763603978&permissions=8&scope=bot
intents = discord.Intents.default()
intents.members = True
client = Bot(command_prefix='!', intents=intents)
load_dotenv('.env')
async def load_channel(guild, name):
if find_channel(guild, name) is None:
return await guild.create_voice_channel(name)
else:
return find_channel(guild, name)
def find_channel(guild, name):
for channel in guild.channels:
if channel.name == name:
return channel
return None
@client.event
async def on_ready():
print(f'{client.user} has connected to Discord!')
for guild in client.guilds:
guildDict[guild] = {'funnyMeme': False, 'Scrim Lobby': await load_channel(guild, 'Scrim Lobby')}
for channel in guild.voice_channels:
if channel.user_limit == 1:
guildDict[guild]["lonely"] = channel
print(f'{channel.name} is desinated as lonely')
@client.event
async def on_voice_state_update(member, before, after):
if before.channel is not None:
guild = before.channel.guild
else:
guild = after.channel.guild
lonely = guildDict[guild]['lonely']
if guildDict[guild]['funnyMeme']:
#On user leave channel
if before.channel is not None and after.channel is None:
if len(before.channel.members) == 1:
await before.channel.members[0].move_to(lonely)
print(f'{member.nick} sent to the lonely corner')
#On user join channel
elif before.channel is None and after.channel is not None:
if len(after.channel.members) == 1:
if len(lonely.members) == 0:
await after.channel.members[0].move_to(lonely)
print(f'{member.nick} sent to the lonely corner')
elif len(lonely.members) == 1:
await lonely.members[0].move_to(after.channel)
print(f'{member.nick} sent to a friend')
#on user change channel
elif before.channel is not after.channel:
if after.channel != lonely:
if len(after.channel.members) == 1:
await after.channel.members[0].move_to(lonely)
print(f'{member.nick} sent to the lonely corner')
elif len(before.channel.members) == 1:
await before.channel.members[0].move_to(lonely)
print(f'{member.nick} sent to the lonely corner')
# @client.command()
# async def scrim(ctx):
# if not guildDict[ctx.guild]['scrim']:
# guildDict[ctx.guild]['scrim'] = True
#
# guildDict[ctx.guild]['scrimLobby'] = await ctx.guild.create_voice_channel('Scrim Lobby')
# await ctx.send("Everyone join the scrim lobby.\n When ready send the start command")
@client.command(brief=os.getenv('START_BRIEF'), description=os.getenv('START_DESCRIPTION'))
async def start(ctx):
if guildDict[ctx.guild]['Scrim Lobby'] is None:
await ctx.send("Some shitty programmer just fuck up. Sorry!\nDon't worry i'll fix it\n"
"Feel free to join the 'Scrim Lobby' and try again")
guildDict[ctx.guild]['Scrim Lobby'] = await load_channel(ctx.guild, 'Scrim Lobby')
return -1
guildDict[ctx.guild]['teamA'] = await load_channel(ctx.guild, 'teamA')
guildDict[ctx.guild]['teamB'] = await load_channel(ctx.guild, 'teamB')
bus = guildDict[ctx.guild]['Scrim Lobby'].members
await distribute(bus, [guildDict[ctx.guild]['teamA'], guildDict[ctx.guild]['teamB']])
async def distribute(roster, destinations):
print([member.nick for member in roster])
random.shuffle(roster)
print([member.nick for member in roster])
print([channel.name for channel in destinations])
random.shuffle(destinations)
print([channel.name for channel in destinations])
for i, cannonFodder in enumerate(roster):
await cannonFodder.move_to(destinations[i % len(destinations)])
@client.command(brief=os.getenv('chaos_brief'), description=os.getenv('chaos_description'))
async def chaos(ctx):
if ctx.author.guild_permissions.move_members or ctx.author.id == int(os.getenv('SHADE_ID')):
await ctx.send(f"{ctx.author.nick}, We shall dance together in madness")
print(f"{ctx.author.nick}, We shall dance together in madness")
channelList = []
memberList = []
for channel in ctx.guild.voice_channels:
channelList.append(channel)
memberList += channel.members
await distribute(memberList, channelList)
else:
await ctx.send(f"{ctx.author.nick}, can't let you do that")
print(f"{ctx.author.nick}, can't let you do that")
@client.command(brief=os.getenv('scramble_brief'), description=os.getenv('scramble_description'))
async def scramble(ctx):
if guildDict[ctx.guild]['teamA'] is None or guildDict[ctx.guild]['teamA'] is None or \
guildDict[ctx.guild]['Scrim Lobby'] is None:
await ctx.send("Oops looks like some of the channels for this command are missing,\n "
"Don't worry i'll remake them, feel free to try the command again")
guildDict[ctx.guild]['teamA'] = await load_channel(ctx.guild, 'teamA')
guildDict[ctx.guild]['teamB'] = await load_channel(ctx.guild, 'teamB')
guildDict[ctx.guild]['Scrim Lobby'] = await load_channel(ctx.guild, 'Scrim Lobby')
else:
roster = guildDict[ctx.guild]['Scrim Lobby'].members + guildDict[ctx.guild]['teamB'].members + guildDict[ctx.guild]['teamA'].members
print(roster)
random.shuffle(roster)
print(roster)
if random.choice(range(2)):
for index, child in enumerate(roster):
if index % 2:
await child.move_to(guildDict[ctx.guild]['teamA'])
else:
await child.move_to(guildDict[ctx.guild]['teamB'])
else:
for index, child in enumerate(roster):
if index % 2:
await child.move_to(guildDict[ctx.guild]['teamB'])
else:
await child.move_to(guildDict[ctx.guild]['teamA'])
async def abandon_ship(ship, land):
for crew in ship.members:
await crew.move_to(land)
await ship.delete()
@client.command(brief=os.getenv('stop_brief'), description=os.getenv('stop_description'))
async def stop(ctx):
if guildDict[ctx.guild]['Scrim Lobby'] is None:
await ctx.send("Ohh No, that wasn't supposed to happen.")
return -1
guildDict[ctx.guild]['teamA'] = await load_channel(ctx.guild, 'teamA')
if guildDict[ctx.guild]['teamA'] is not None:
await abandon_ship(guildDict[ctx.guild]['teamA'], guildDict[ctx.guild]['Scrim Lobby'])
guildDict[ctx.guild]['teamB'] = await load_channel(ctx.guild, 'teamB')
if guildDict[ctx.guild]['teamB'] is not None:
await abandon_ship(guildDict[ctx.guild]['teamB'], guildDict[ctx.guild]['Scrim Lobby'])
@client.command(brief=os.getenv('fuckingStop_brief'), description=os.getenv('fuckingStop_description'))
async def fuckingStop(ctx):
guildDict[ctx.guild]['funnyMeme'] = False
await ctx.send("Sorry, i'll stop.")
@client.command(brief=os.getenv('meme_brief'), description=os.getenv('meme_description'))
async def meme(ctx):
guildDict[ctx.guild]['funnyMeme'] = True
await ctx.send("You Fool!, you have no idea the power you unleashed")
@client.command(brief=os.getenv('coin_brief'), description=os.getenv('coin_description'))
async def coin(ctx):
coin = ['heads', 'tails']
await ctx.send(random.choice(coin))
@client.command(brief=os.getenv('buly_brief'), description=os.getenv('buly_description'))
async def buly(ctx):
await ctx.send("{} {}".format(ctx.author.mention, "Damn, can't even spell bully right"))
async def bullyMesage(ctx,message):
if len(ctx.message.mentions) == 0 and len(ctx.message.role_mentions) == 0:
print("I'm rubber your glue")
temp = ctx.author.mention
elif len(ctx.message.mentions) > 0:
print(ctx.message.mentions)
temp = ctx.message.mentions[0].mention
else:
temp = ctx.message.role_mentions[0].mention
ident = id_to_int(temp)
if ident == int(os.getenv('SHADE_ID')):
print("Master messaged")
if random.choice(range(2)) == 1:
message = "Master is the best"
elif ident == int(os.getenv('CAT_ID')):
if random.choice(range(10)) == 5:
message = "SAD CAT next time!"
await ctx.send("{} {}".format(temp, message))
def id_to_int(id):
str = ""
for i in id:
if re.match("[0-9]", i):
str = str + i
return int(str)
@client.command(brief=os.getenv('BULLY_BRIEF'), description=os.getenv('BULLY_DESCRIPTION'))
async def BULLY(ctx):
await bully(ctx)
@client.command(brief=os.getenv('bullie_brief'), description=os.getenv('bullie_description'))
async def bully(ctx):
if random.choice(range(100)) == 50:
await bullyMesage(ctx, " is the coolest")
else:
await bullyMesage(ctx, random.choice(insults))
@client.command(brief=os.getenv('gay_brief'), description=os.getenv('gay_description'))
async def gay(ctx):
await ctx.send(file=discord.File('youGay.png'))
@client.command(brief=os.getenv('catgirl_brief'), description=os.getenv('catgirl_description'))
async def catgirl(ctx):
if random.choice(range(10)) == 9:
await ctx.send(file=discord.File('cap yeet.jpg'))
else:
await ctx.send(file=discord.File('Bella.png'))
if __name__ == "__main__":
guildDict = {}
TOKEN = os.getenv('DISCORD_TOKEN')
insults = []
with open('insults.txt') as file:
for line in file:
insults.append(line)
client.run(TOKEN)