-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHacksuDiscordBot.py
More file actions
38 lines (27 loc) · 1.21 KB
/
HacksuDiscordBot.py
File metadata and controls
38 lines (27 loc) · 1.21 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
import discord
import asyncio
import datetime
class MyClient(discord.Client):
async def on_message(self,message):
if(message.content.startswith("/")):
await self.process_commands(message)
async def process_commands(self,message):
command = message.content.split()[0].lower()
#Command List Here
if(command == "/time"):
await self.give_time(message)
else:
await message.channel.send("Invalid command: my only command is `/time`")
async def give_time(self,message):
crnt_time = datetime.datetime.now()
await message.channel.send("The current time is: " + str(crnt_time.hour)+":"+str(crnt_time.minute)+":"+str(crnt_time.second)+"!")
async def on_ready(self):
await self.change_presence(activity=discord.Game(name = "/time"))
print("Successfully set Bot's game status")
async def on_connect(self):
print("Bot has connected to server at time:",datetime.datetime.now())
async def on_disconnect(self):
print("Bot has disconnected from server at time:",datetime.datetime.now())
print("Starting Bot")
bot = MyClient()
bot.run("TOKEN")