-
Notifications
You must be signed in to change notification settings - Fork 0
/
wallet_reg.py
46 lines (36 loc) · 1.47 KB
/
wallet_reg.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
import json
import discord
from discord import app_commands
from discord.ext import commands
TOKEN = ""
intents = discord.Intents.all()
intents.members = True
intents.message_content = True
client = commands.Bot(command_prefix="/", intents=intents)
@client.event
async def on_ready():
print("Bot is Up and Ready!")
try:
synced = await client.tree.sync()
print(f"Synced {len(synced)} command(s)")
except Exception as e:
print(e)
js_data = {}
@client.tree.command(name="register")
@app_commands.describe(addr="Register your wallet address.")
async def wallet(interaction: discord.Interaction, addr: str = None):
if addr.startswith("addr1"):
if interaction.user.id in js_data:
await interaction.response.send_message("Already Registered.")
else:
with open("wallet_list.json", 'w', encoding='utf-8') as f:
js_data[interaction.user.id] = {"name": interaction.user.name, "wallet": addr}
json.dump(js_data, f, ensure_ascii=False, indent=4)
await interaction.response.send_message(f"Address ending in {addr[-5:]} has been registered.")
elif addr.startswith("$"):
await interaction.response.send_message(f"We do not support adaHandles at this time.")
else:
await interaction.response.send_message(f"Wallet entry of {addr}"
f"doesn't match any known Cardano address patterns.")
print(js_data)
client.run(TOKEN)