-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
76 lines (66 loc) · 2.26 KB
/
main.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
from tokens import TOKEN
import discord
import random
import json
try:
with open('db.json','x') as f: pass
with open('db.json','w') as f:
f.write('{"":0}')
except: pass
intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)
tree = discord.app_commands.CommandTree(client)
db:dict = {}
@client.event
async def on_ready():
await tree.sync()
print("Ready!")
boops = [
discord.File(fp='Boops/White1.gif'),
discord.File(fp='Boops/White2.gif'),
discord.File(fp='Boops/Black1.gif'),
discord.File(fp='Boops/Black2.gif'),
discord.File(fp='Boops/Orange1.gif'),
discord.File(fp='Boops/Orange2.gif')
]
async def boop(type, victim, attacker):
if type == 1:
await attack(victim, attacker, 0)
elif type == 2:
await attack(victim, attacker, 1)
elif type == 3:
await attack(victim, attacker, 2)
async def attack(victim, attacker, attackType:int):
attacks = ['booped','exploded','imploded']
with open('db.json', 'r') as f:
db = json.load(f)
try: db[f'{victim}'][attackType] += 1
except:
db[f'{victim}'] = [0,0,0]
db[f'{victim}'][attackType] += 1
with open('db.json', 'w') as f:
json.dump(db, f)
await victim.send(f'You have been {attacks[attackType]} by <@{attacker}>. You have been {attacks[attackType]} {db[f"{victim}"][attackType]} times.',)
@tree.command(
name="boop",
description="Boops a given target"
)
async def booperr(interaction, target: discord.Member):
await boop(1, target, interaction.user.id)
await interaction.response.send_message(f'Succesfully Booped {target.name.capitalize()}')
@tree.command(
name="explode",
description="'Explodes' a given target"
)
async def explode(interaction, target: discord.Member):
await boop(2, target, interaction.user.id)
await interaction.response.send_message(f'Succesfully Exploded {target.name.capitalize()}')
@tree.command(
name="implode",
description="'Implodes' a given target"
)
async def implode(interaction, target: discord.Member):
await boop(3, target, interaction.user.id)
await interaction.response.send_message(f'Succesfully imploded {target.name.capitalize()}')
client.run(TOKEN)