-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspbot.py
37 lines (33 loc) · 1.17 KB
/
spbot.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
import discord
from discord.ext import commands
import backend.rqstate as rqstate
import os
bot = commands.Bot(command_prefix=",,")
bot.remove_command("help")
rq = rqstate.RQState("resources/rooms.json")
@bot.event
async def on_message(message):
if message.author.bot or not(message.content.startswith("SP ") or message.content.startswith("sp ")):
return
channel = message.channel
name = str(message.author)
if name not in rq.players:
rq.loadPlayer(name)
msg = str(message.content)[2:].lstrip()
if msg:
rq.parseMessage(name, msg)
rq.printState(name)
membed = discord.Embed(title="SPRQ", type="rich")
membed.add_field(name=f"Replying to {name}", value=os.linesep.join(rq.getMessages(name)), inline=True)
await channel.send(embed=membed)
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
return
elif isinstance(error, commands.MissingRequiredArgument):
return
elif isinstance(error, commands.CommandOnCooldown):
await ctx.send(f"**{ctx.author}**, this command is on cooldown. Try again in {error.retry_after} seconds")
else:
await ctx.send(str(error) + "\n")
bot.run(str(os.getenv("TOKEN")), bot=True, reconnect=True)