-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
125 lines (91 loc) · 3.22 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
import discord
from discord.ext import commands
from discord.flags import Intents
from dotenv import load_dotenv
import os
from utils.bot_status import keep_alive
load_dotenv()
TOKEN = os.getenv("TOKEN")
GUILD = int(os.getenv("GUILD"))
BOT_LUMINARY = int(os.getenv("BOT_LUMINARY"))
WELCOME = int(os.getenv("WELCOME"))
BLDISC = int(os.getenv("BLDISC"))
SPLFREE = int(os.getenv("SPLFREE"))
MOD_LOGS = int(os.getenv("MOD_LOGS"))
RXROLES = int(os.getenv("RXROLES"))
RX_HOUSES = int(os.getenv("RXHOUSES"))
RX_ANNOUNCEMENTS = int(os.getenv("RXANNOUNCEMENTS"))
intents = discord.Intents.default()
intents.members = True
intents.reactions = True
bot = commands.Bot(command_prefix=';', intents=intents)
@bot.event
async def on_ready():
await bot.change_presence(
activity=discord.Game(name="Black Luminary")
)
@bot.event
async def on_member_join(member):
channel = bot.get_channel(WELCOME)
bldisc = bot.get_channel(BLDISC)
splfree = bot.get_channel(SPLFREE)
welcome = f"Welcome to Black Luminary, {member.mention}! Head over to {bldisc.mention} if you're caught up with the fic, or to {splfree.mention} if you're looking to discuss it while reading!"
await channel.send(welcome)
rx_dict_houses = {
"gryffindor": "Gryffindor",
"ravenclaw": "Ravenclaw",
"slytherin": "Slytherin",
"hufflepuff": "Hufflepuff"
}
rx_dict_announcements = {
"🗒️": "Story News",
"📣": "Announcements"
}
rx_dict_master = {
"RX_HOUSES": [RX_HOUSES, rx_dict_houses],
"RX_ANNOUNCEMENTS": [RX_ANNOUNCEMENTS, rx_dict_announcements]
}
@bot.event
async def on_raw_reaction_add(payload):
for i in rx_dict_master.keys():
if payload.message_id == rx_dict_master[i][0]:
dict_to_use = rx_dict_master[i][1]
emote = payload.emoji.name
guild_id = payload.guild_id
guild = discord.utils.find(
lambda g: g.id == guild_id, bot.guilds
)
if emote in dict_to_use.keys():
role = discord.utils.get(
guild.roles, name=dict_to_use[emote]
)
member = discord.utils.find(
lambda m: m.id == payload.user_id, guild.members
)
await member.add_roles(role)
@bot.event
async def on_raw_reaction_remove(payload):
for i in rx_dict_master.keys():
if payload.message_id == rx_dict_master[i][0]:
dict_to_use = rx_dict_master[i][1]
emote = payload.emoji.name
guild_id = payload.guild_id
guild = discord.utils.find(
lambda g: g.id == guild_id, bot.guilds
)
if emote in dict_to_use.keys():
role = discord.utils.get(
guild.roles, name=dict_to_use[emote]
)
member = discord.utils.find(
lambda m: m.id == payload.user_id, guild.members
)
await member.remove_roles(role)
@bot.event
async def on_message(message):
# To run bot.commands & bot.event simultaneously
await bot.process_commands(message)
keep_alive() # To start the flask server
bot.load_extension("cogs.logs")
bot.load_extension("cogs.moderation")
bot.run(TOKEN)