forked from khandyman/SOS-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
75 lines (56 loc) · 1.77 KB
/
Copy pathmain.py
File metadata and controls
75 lines (56 loc) · 1.77 KB
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
# bot.py
import os
import discord # actually using py-cord instead of discord.py
from classes.database import Database
from classes.tracker import Tracker
from dotenv import load_dotenv
load_dotenv() # sets up environment variables, stored locally in .env
TOKEN = os.getenv('DISCORD_TOKEN') # bot token
GUILD = os.getenv('DISCORD_GUILD') # target guild
discord_names = [] # list of Discord names
# give bot access to all Discord intents and
# instantiate database and helper classes
intents = discord.Intents.all()
bot = discord.Bot(intents=intents)
database = Database()
tracker = Tracker()
@bot.event
async def on_connect():
# load slash command classes
bot.load_extension("cogs.lookups")
bot.load_extension("cogs.updates")
await bot.sync_commands()
@bot.event
async def on_ready():
"""
start up function: gets guild instance
and starts keep alive routine
:return: none
"""
guild = discord.utils.get(bot.guilds, name=GUILD)
print(
f'{bot.user} has connected to the following guild:\n'
f'{guild.name} (id: {guild.id})'
)
# keep_alive.start()
# find_discrepancies(guild)
def find_discrepancies(guild):
characters = database.get_discord_ids()
discrepancies = []
found = False
for char_dict in characters:
for member in guild.members:
if str(char_dict['discord_id']) == str(member.id):
found = True
break
if found is False:
current_char = {
"discord_id": char_dict['discord_id'],
"char_name": char_dict['char_name']
}
discrepancies.append(current_char)
found = False
for item in discrepancies:
print(item)
if __name__ == "__main__":
bot.run(TOKEN)