-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
144 lines (104 loc) · 4.47 KB
/
main.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
import discord
import random
import os # allows access into .env files
from discord.ext import commands, tasks
from keep_alive import keep_alive
intents = discord.Intents.all()
intents.members = True
bot = commands.Bot(command_prefix = '.', intents = intents)
# random statuses
stat = [discord.Status.online, discord.Status.idle, discord.Status.dnd]
# random activities
act = [discord.Game('Gridshot'), discord.Game('myself :/'),
discord.Game('Tik Tak Toe'), discord.Game('BEYBLADE'), discord.Game('Yu-Gi-Oh!'),
discord.Game('Pokémon GO'), discord.Game('Pocket God'),
discord.Game('coolmathgames.com'), discord.Game('Search and Destroy in Terminal'),
discord.Game('Unrated'), discord.Game('Ranked'), discord.Game('Spike Rush'), discord.Game('Deathmatch'), discord.Game('CLIX Box Fights'),
discord.Activity(type=discord.ActivityType.listening, name='Ram Ranch'),
discord.Activity(type=discord.ActivityType.listening, name='NIKI'),
discord.Activity(type=discord.ActivityType.listening, name='Joji'),
discord.Activity(type=discord.ActivityType.watching, name='TenZ'),
discord.Activity(type=discord.ActivityType.watching, name='GoT'),
discord.Activity(type=discord.ActivityType.watching, name='Rick and Morty')]
# TASKS
@tasks.loop(hours=1)
async def change_status():
await bot.change_presence(status=discord.Status.dnd, activity=random.choice(act))
# EVENTS
@bot.event
async def on_ready():
change_status.start()
print(f'{bot.user.name} is all set')
@bot.event
async def on_member_join(member):
channel = bot.get_channel(721275182752464919)
await channel.send(f'**{member.name}** is now a sweat! welcome <:hot_face:795781546047963187> <:sweat_drops:795781585789911040>')
@bot.event
async def on_message(message):
if message.author.bot:
return
if '10 man' in message.content:
await message.channel.send('<:billed_cap:793982003820101662>')
# allows commands to be called async
await bot.process_commands(message)
@bot.event
async def on_raw_reaction_add(payload):
message_id = payload.message_id
if message_id == 793644726170681364:
guild_id = payload.guild_id
guild = discord.utils.find(lambda g : g.id == guild_id, bot.guilds)
role = discord.utils.get(guild.roles, name=payload.emoji.name)
if role is not None:
member = payload.member
if member is not None:
await member.add_roles(role)
print(f'{role} role added to {member}')
else:
print('member not found')
else:
print('role not found')
@bot.event
async def on_raw_reaction_remove(payload):
message_id = payload.message_id
if message_id == 793644726170681364:
guild_id = payload.guild_id
guild = discord.utils.find(lambda g : g.id == guild_id, bot.guilds)
role = discord.utils.get(guild.roles, name=payload.emoji.name)
if role is not None:
# payload.member only works when adding a role
member = await guild.fetch_member(payload.user_id)
if member is not None:
await member.remove_roles(role)
print(f'{role} role removed from {member}')
else:
print('member not found')
else:
print('role not found')
# catches general errors
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
await ctx.send('Command does not exist boi')
# COMMANDS
@bot.command()
async def load(ctx, extension):
bot.load_extension(f'cogs.{extension}')
@bot.command()
async def unload(ctx, extension):
bot.unload_extension(f'cogs.{extension}')
@bot.command() # returns the ping of the user
async def ping(ctx):
await ctx.send(f'<:ping_pong:793995689825665035>pong! {round(bot.latency * 1000)}ms')
@bot.command() # returns the minecraft server name
async def mcserver(ctx):
await ctx.send('MINECRAFT SERVER <:MINECRAFT:793628933123211264>\nmc.bighatchet.com:7357')
@bot.command()
@commands.has_permissions(manage_messages=True) # check which limits which users can call this command
async def clear(ctx, amount = 1):
await ctx.channel.purge(limit = amount + 1)
# includes all the cogs/classes in program
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
bot.load_extension(f'cogs.{filename[:-3]}')
keep_alive() # keeps bot running
bot.run(os.getenv('token')) # uses bots token to begin running