1- """"
2- Copyright © Krypton 2019-2023 - https://github.com/kkrypt0nn (https://krypton.ninja)
1+ """
2+ Copyright © Krypton 2019-Present - https://github.com/kkrypt0nn (https://krypton.ninja)
33Description:
4- 🐍 A simple template to start to code your own and personalized discord bot in Python programming language.
4+ 🐍 A simple template to start to code your own and personalized Discord bot in Python
55
6- Version: 6.1 .0
6+ Version: 6.2 .0
77"""
88
99import platform
1616from discord .ext .commands import Context
1717
1818
19+ class FeedbackForm (discord .ui .Modal , title = "Feeedback" ):
20+ feedback = discord .ui .TextInput (
21+ label = "What do you think about this bot?" ,
22+ style = discord .TextStyle .long ,
23+ placeholder = "Type your answer here..." ,
24+ required = True ,
25+ max_length = 256 ,
26+ )
27+
28+ async def on_submit (self , interaction : discord .Interaction ):
29+ self .interaction = interaction
30+ self .answer = str (self .feedback )
31+ self .stop ()
32+
33+
1934class General (commands .Cog , name = "general" ):
2035 def __init__ (self , bot ) -> None :
2136 self .bot = bot
@@ -264,9 +279,7 @@ async def bitcoin(self, context: Context) -> None:
264279 "https://api.coindesk.com/v1/bpi/currentprice/BTC.json"
265280 ) as request :
266281 if request .status == 200 :
267- data = await request .json (
268- content_type = "application/javascript"
269- ) # For some reason the returned content is of type JavaScript
282+ data = await request .json ()
270283 embed = discord .Embed (
271284 title = "Bitcoin price" ,
272285 description = f"The current price is { data ['bpi' ]['USD' ]['rate' ]} :dollar:" ,
@@ -280,6 +293,36 @@ async def bitcoin(self, context: Context) -> None:
280293 )
281294 await context .send (embed = embed )
282295
296+ @app_commands .command (
297+ name = "feedback" , description = "Submit a feedback for the owners of the bot"
298+ )
299+ async def feedback (self , interaction : discord .Interaction ) -> None :
300+ """
301+ Submit a feedback for the owners of the bot.
302+
303+ :param context: The hybrid command context.
304+ """
305+ feedback_form = FeedbackForm ()
306+ await interaction .response .send_modal (feedback_form )
307+
308+ await feedback_form .wait ()
309+ interaction = feedback_form .interaction
310+ await interaction .response .send_message (
311+ embed = discord .Embed (
312+ description = "Thank you for your feedback, the owners have been notified about it." ,
313+ color = 0xBEBEFE ,
314+ )
315+ )
316+
317+ app_owner = (await self .bot .application_info ()).owner
318+ await app_owner .send (
319+ embed = discord .Embed (
320+ title = "New Feedback" ,
321+ description = f"{ interaction .user } (<@{ interaction .user .id } >) has submitted a new feedback:\n ```\n { feedback_form .answer } \n ```" ,
322+ color = 0xBEBEFE ,
323+ )
324+ )
325+
283326
284327async def setup (bot ) -> None :
285328 await bot .add_cog (General (bot ))
0 commit comments