-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
44 lines (28 loc) · 984 Bytes
/
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
from datetime import datetime
import os
import discord
from discord import Message
from commands import get_commands
TOKEN = os.environ.get("DISCORD_TOKEN")
client = discord.Client()
@client.event
async def on_ready():
print("Logged in as")
print(client.user.name)
print(client.user.id)
print("------")
print("Setting bot presence")
activity = discord.Game(name="?h")
await client.change_presence(status=discord.Status.online, activity=activity)
print("Setup done!")
COMMANDS = get_commands()
@client.event
async def on_message(message: Message):
if message.content.startswith("?"):
command, *arg_string = message.content.split(" ", 1)
arg_string = arg_string[0] if arg_string else ""
print(f"Command {command} called by {message.author.name}")
if COMMANDS.get(command):
reply = await COMMANDS[command](message, arg_string)
await message.channel.send(reply)
client.run(TOKEN)