This repository was archived by the owner on May 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
48 lines (38 loc) · 1.31 KB
/
bot.py
File metadata and controls
48 lines (38 loc) · 1.31 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
39
40
41
42
43
44
45
46
47
48
import discord
from annotation import Annotation
from context import ctx
from init import bootstrap
intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)
@client.event
async def on_ready():
ctx.logger.info('Logged in as {0.user}'.format(client))
def handle_command(message):
match message.content.split(' '):
case ['$describe', item, *xs] if xs != []:
author = message.author.display_name
description = ' '.join(xs)
item = item.lower()
return anno.describe(author, item, description)
case ['$about' | '$info', item]:
item = item.lower()
return anno.about(item)
case ['$ping']:
return 'pong'
case ['$help']:
return 'Commands available:\nabout <item>\ndescribe <item> <description>\nping'
case _:
return 'sorry I did not understand that'
@client.event
async def on_message(message):
for embed in message.embeds:
dict = embed.to_dict()
await message.channel.send(anno.redact(dict))
if message.author == client.user:
return
if message.content.startswith('$'):
await message.channel.send(handle_command(message))
anno = Annotation(ctx)
bootstrap(ctx, anno)
client.run(ctx.discord_token)