-
Notifications
You must be signed in to change notification settings - Fork 3
/
bot.py
71 lines (56 loc) · 1.95 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
import os
import discord
import asyncio
import pickle
import threading
from client import Client
from dotenv import load_dotenv
from discord.ext.commands import Bot
load_dotenv()
TOKEN = os.getenv("DISCORD_TOKEN")
GUILD = int(os.getenv("DISCORD_GUILD"))
CHANNEL = int(os.getenv("DISCORD_CHANNEL"))
ROLE = int(os.getenv("ROLE"))
ping = ['Queen of Hearts', 'Yazanahar', 'Larry Gigsman', 'Sorgigas', 'Mothership', 'Stone Gargoyle', 'Tod', "The Horrific"]
with open("NameDictionary.pkl", "rb") as f:
nameDictionary = pickle.load(f)
client = Client(nameDictionary)
if not client.initializeAccountDetails():
print("Encountered exception in initializing account details. Quitting.")
if not client.loadModules():
print("No module was loaded. Quitting.")
intents = discord.Intents.all()
bot = Bot(command_prefix="-")
async def tracker():
await bot.wait_until_ready()
channel = bot.get_channel(CHANNEL)
while not bot.is_closed():
if client.module.needsDisplay:
here = False
for i in ping:
if i in client.module.questName:
here = True
if here:
await channel.send("<@&{}> ".format(ROLE) + client.module.questName + " spawned in realm.")
else:
pass
client.module.needsDisplay = False
await asyncio.sleep(0.5)
while not client.messageQueue.empty():
await channel.send(client.messageQueue.get())
@bot.event
async def on_ready():
guild = discord.utils.find(lambda g: g.id == GUILD, bot.guilds)
print(
f'{bot.user} is connected to the following guild:\n'
f'{guild.name}(id: {guild.id})'
)
@bot.event
async def on_member_update(before, after):
return
loop = asyncio.get_event_loop()
loop.create_task(bot.start(TOKEN))
loop.create_task(tracker())
threading.Thread(target = loop.run_forever, daemon = True).start()
print("Started discord bot thread.")
client.mainLoop()