This repository has been archived on 2025-01-28. You can view files and clone it, but cannot push or open issues or pull requests.
natsuko/cogs/stickers.py

41 lines
1.5 KiB
Python
Raw Normal View History

2023-05-03 19:53:01 +03:00
import discord
from discord import app_commands
from discord.app_commands import Choice
from discord.ext import commands, tasks
from os import listdir
2023-05-07 01:55:55 +03:00
from os.path import splitext, join
dir = "Stickers"
2023-05-03 19:53:01 +03:00
class Stickers(commands.Cog, name="Стикеры"):
def __init__(self, bot):
self.bot = bot
@commands.command(aliases=["sl"])
2023-05-09 00:18:20 +03:00
@app_commands.guilds(discord.Object(822157545622863902))
2023-05-03 19:53:01 +03:00
async def sticker_list(self, ctx):
if ctx.guild is not None:
color = ctx.guild.me.color
if color == discord.Color.default():
color = discord.Color(0xaaffaa)
else:
color = discord.Color(0xaaffaa)
2023-05-07 01:55:55 +03:00
list_ = listdir(dir)
2023-05-03 19:53:01 +03:00
embed = discord.Embed(title="Стикеры", description="\n".join([f"{i+1}: {list_[i]}" for i in range(len(list_))]), color=color)
await ctx.send(embed=embed)
@app_commands.command(name="sticker", description="Отправляет стикер")
@app_commands.guilds(discord.Object(822157545622863902))
@app_commands.describe(sticker="Стикер")
2023-05-07 01:55:55 +03:00
@app_commands.choices(sticker=[Choice(name=splitext(i)[0], value=i) for i in listdir(dir)])
2023-05-03 19:53:01 +03:00
async def send_sticker(self, inter, sticker: Choice[str]):
2023-05-07 01:55:55 +03:00
with open(join(dir, sticker.value), 'rb') as f:
2023-05-03 19:53:01 +03:00
await inter.response.send_message(file=discord.File(f))
async def setup(bot):
await bot.add_cog(Stickers(bot))