Skip to content

Commit 5a98cf1

Browse files
committed
Added context menu
1 parent 206852f commit 5a98cf1

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

cogs/context_menu/c_fun.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import discord
2+
from discord import app_commands
3+
from discord.ext import commands
4+
5+
from classes.quote_image_creator import QuoteImageCreator
6+
7+
class CFun(commands.Cog):
8+
"""Fun"""
9+
10+
def __init__(self, bot) -> None:
11+
self.bot = bot
12+
self.ctx_menu = app_commands.ContextMenu(
13+
name="Сделать Цитату",
14+
callback=self.quote, # set the callback of the context menu to "my_cool_context_menu"
15+
)
16+
self.bot.tree.add_command(self.ctx_menu) # add the context menu to the tree
17+
18+
async def quote(self, interaction: discord.Interaction, message: discord.Message) -> None:
19+
if len(message.content) > 135:
20+
await interaction.response.send_message("⚠️ ЭЭЭээээ слиш ти педрило-хуило, низя больше 135 символов в цитати, "
21+
"ти миня понеЛ?!!!?!??!11?!?!",
22+
delete_after=10)
23+
elif len(message.content) < 1:
24+
await interaction.response.send_message("⚠️ ээээиий вай вах дАрагои, што ти дэлат?! "
25+
"нужна хатябы 1 букава для цытати, мой дарагои, ваххх",
26+
delete_after=10)
27+
else:
28+
quote_generator = QuoteImageCreator('assets/back.jpg')
29+
quote_image = quote_generator.create_quote_image(message.content, message.author.name)
30+
await interaction.response.send_message(file=discord.File(quote_image))
31+
32+
async def setup(bot):
33+
await bot.add_cog(CFun(bot))

main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from cogs import converters, fun, help, moderation, information, music, listeners, text
2+
from cogs.context_menu import c_fun
23
from cogs.slash import s_fun, s_text, s_music, s_moderation, s_converters
34
from config import settings
45
import sys
@@ -25,6 +26,7 @@
2526
asyncio.run(music.setup(bot))
2627
asyncio.run(listeners.setup(bot))
2728
asyncio.run(text.setup(bot))
29+
asyncio.run(c_fun.setup(bot))
2830
asyncio.run(s_fun.setup(bot))
2931
asyncio.run(s_text.setup(bot))
3032
asyncio.run(s_music.setup(bot))

0 commit comments

Comments
 (0)