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)
3
3
Description:
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
5
5
6
- Version: 6.1 .0
6
+ Version: 6.2 .0
7
7
"""
8
8
9
9
import platform
16
16
from discord .ext .commands import Context
17
17
18
18
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
+
19
34
class General (commands .Cog , name = "general" ):
20
35
def __init__ (self , bot ) -> None :
21
36
self .bot = bot
@@ -264,9 +279,7 @@ async def bitcoin(self, context: Context) -> None:
264
279
"https://api.coindesk.com/v1/bpi/currentprice/BTC.json"
265
280
) as request :
266
281
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 ()
270
283
embed = discord .Embed (
271
284
title = "Bitcoin price" ,
272
285
description = f"The current price is { data ['bpi' ]['USD' ]['rate' ]} :dollar:" ,
@@ -280,6 +293,36 @@ async def bitcoin(self, context: Context) -> None:
280
293
)
281
294
await context .send (embed = embed )
282
295
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
+
283
326
284
327
async def setup (bot ) -> None :
285
328
await bot .add_cog (General (bot ))
0 commit comments