-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
60 lines (47 loc) · 2.19 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
import discord
from discord.ext import commands
import platform
import asyncio
import sqlite3
import private_key
import datetime
cog_list = ["cogs.currency"]
print(f'Initializing currency.db')
conn = sqlite3.connect("currency.db", detect_types=sqlite3.PARSE_DECLTYPES)
c = conn.cursor()
c.execute(
"CREATE TABLE IF NOT EXISTS currency (UID integer PRIMARY KEY, name TEXT, balance INTEGER DEFAULT 0, rob TIMESTAMP)")
class DragonHoard(commands.Bot):
def __init__(self):
super().__init__(description="DragonHoard", command_prefix="!", case_insensitive=True, pm_help=False)
for cog in cog_list:
self.load_extension(cog)
def add_user_to_database(self, user):
c.execute("INSERT OR IGNORE into currency (UID, name, balance, rob) VALUES (?,?,?,?)",
[user.id, user.name, 100, datetime.datetime.now()])
conn.commit()
async def on_ready(self): # Tells us info about the bot and readys the bot for taking commands
print(f'Logged in as {self.user.name} (ID:{self.user.id}')
# Username and ID
print('--------')
print(
f'Current Discord.py Version: {discord.__version__} | Current Python Version: {platform.python_version()}')
# Discord and Python version
print('--------')
print(f'Use this link to invite {self.user.name}:')
print(f'https://discordapp.com/oauth2/authorize?client_id={self.user.id}&scope=bot&permissions=8')
# prints a link that you may use to invite to your server
user_list = self.get_all_members()
for x in user_list:
self.add_user_to_database(x)
# adds current users to database
async def on_message(self, message):
if message.author != self.user: # just stops the bot from noticing its own messages
pass # await message.channel.send("fuck you conic")
await self.process_commands(message)
async def on_member_join(self, member): # adds new member to database and welcomes them
self.add_user_to_database(member)
await member.guild.channels[1].send(f"Welcome {member.mention}")
if __name__ == "__main__":
client = DragonHoard()
client.run(private_key.private_key)