This repository has been archived by the owner on Jan 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
71 lines (54 loc) · 1.62 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 discord
import config
import csv
import psycopg2
from discord.ext import commands
from database import get_database
"""
bot.py: Discord bot to search for discord users in database
Some inspiration taken from RoboDanny: https://github.com/Rapptz/RoboDanny
"""
__author__ = "Eduard Tanase"
__version__ = "1.0.0"
PREFIX = '~'
COGS = [
"cogs.leave",
"cogs.search",
"cogs.users",
"cogs.update",
"cogs.Events"
]
class MembersBot(commands.Bot):
def __init__(self):
# Configure discord bot
intents = discord.Intents(
guilds=True,
members=True,
messages=True,
reactions=True
)
super().__init__(command_prefix=PREFIX, intents=intents)
# Get bot ID
self.client_id = config.client_id
# Connect to postgresql database with credentials in config.py
self.db = get_database()
self.add_commands()
for cog in COGS:
self.load_extension(cog)
self.log_channel = config.log_channel_id
async def on_ready(self):
# Print info to console
print(f'[INFO]: Ready: {self.user} (ID: {self.user.id})')
def add_commands(self):
@self.command(name="ping", pass_context=True)
async def ping(ctx):
"""
Pings the bot. Also shows latency
:param ctx: Command invoke context
:return: None
"""
print(f"[DEBUG]: Pinged by {ctx.message.author}")
await ctx.send(f"Pong! Latency: {int(self.latency * 1000)} ms")
if __name__ == '__main__':
bot = MembersBot()
bot.run(config.token)