-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin-pewpew.py
40 lines (34 loc) · 1.24 KB
/
plugin-pewpew.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
import fssdb
import random
from xander_plugin import *
db = None
def onload():
global db
help_menu_edit("!shoot", "Shoot a user with a nerf gun.")
help_menu_edit("!pewscore", "Get your score in pew pew minigame.")
log("Pew pew plugin loaded!")
db = fssdb.db(config.fssdbip)
async def onmessage(message):
global db
dname = str(message.author.id)
if message.content.startswith("!shoot "):
hit = bool(random.getrandbits(1))
author = message.author.mention
mention = message.mentions[0].mention
if hit == True:
await message.channel.send(f"{author} shot {mention} with a nerf gun!")
pscore = db.read_point(dname, "pewscore")
if pscore == "DOESNOTEXIST":
pscore = "0"
db.create_dict(dname)
db.write_point(dname, "pewscore", 0)
pscore = int(pscore)
db.write_point(dname, "pewscore", pscore + 1)
else:
await message.channel.send(f"{mention} doged {author}'s dart!")
return False
elif message.content == "!pewscore":
await message.channel.send(f"Your score is {db.read_point(dname, 'pewscore')}")
return True
def onexit():
log("Pew pew plugin exit run.")