-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
38 lines (30 loc) · 1.28 KB
/
Copy pathmain.py
File metadata and controls
38 lines (30 loc) · 1.28 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
import discord
from discord import app_commands,File
import os
import json
with open("config.json",'r') as file:
data = json.load(file)
token = data['token']
guild_id = data['guild_id']
client = discord.Client(intents=discord.Intents.all())
tree = app_commands.CommandTree(client)
guild = discord.Object(id=guild_id)
@client.event
async def on_ready():
await tree.sync(guild=guild)
@tree.command(name="icon",description="Send an icon from the library in chat",guild=guild)
@app_commands.describe(iconname="The name of the icon you want to send. Use /list to see all available options")
async def icon(ctx,*,iconname:str):
for file in os.listdir("images/"):
if iconname.lower() == file.split(".")[0].lower():
icon_file = File(f"images/{file}")
await ctx.response.send_message(file=icon_file)
return
await ctx.response.send_message("Icon not found. Make sure you wrote the name correctly",ephemeral=True)
@tree.command(name="list",description="Get a list of all the icons",guild=guild)
async def list(ctx):
desc = "All the available icons:\n\n"
for file in os.listdir("images/"):
desc += file.split(".")[0]+"\n"
await ctx.response.send_message(desc,ephemeral=True)
client.run(token)