mirror of
https://github.com/neoarz/Syntrel.git
synced 2025-12-25 03:40:11 +01:00
style: new code layout
This commit is contained in:
65
cogs/general/feedback.py
Normal file
65
cogs/general/feedback.py
Normal file
@@ -0,0 +1,65 @@
|
||||
"""
|
||||
Copyright © Krypton 2019-Present - https://github.com/kkrypt0nn (https://krypton.ninja)
|
||||
Description:
|
||||
🐍 A simple template to start to code your own and personalized Discord bot in Python
|
||||
|
||||
Version: 6.4.0
|
||||
"""
|
||||
|
||||
import discord
|
||||
from discord import app_commands
|
||||
from discord.ext import commands
|
||||
|
||||
|
||||
class FeedbackForm(discord.ui.Modal, title="Feeedback"):
|
||||
feedback = discord.ui.TextInput(
|
||||
label="What do you think about this bot?",
|
||||
style=discord.TextStyle.long,
|
||||
placeholder="Type your answer here...",
|
||||
required=True,
|
||||
max_length=256,
|
||||
)
|
||||
|
||||
async def on_submit(self, interaction: discord.Interaction):
|
||||
self.interaction = interaction
|
||||
self.answer = str(self.feedback)
|
||||
self.stop()
|
||||
|
||||
|
||||
class Feedback(commands.Cog, name="feedback"):
|
||||
def __init__(self, bot) -> None:
|
||||
self.bot = bot
|
||||
|
||||
@app_commands.command(
|
||||
name="feedback", description="Submit a feedback for the owners of the bot"
|
||||
)
|
||||
async def feedback(self, interaction: discord.Interaction) -> None:
|
||||
"""
|
||||
Submit a feedback for the owners of the bot.
|
||||
|
||||
:param interaction: The application command interaction.
|
||||
"""
|
||||
feedback_form = FeedbackForm()
|
||||
await interaction.response.send_modal(feedback_form)
|
||||
|
||||
await feedback_form.wait()
|
||||
interaction = feedback_form.interaction
|
||||
await interaction.response.send_message(
|
||||
embed=discord.Embed(
|
||||
description="Thank you for your feedback, the owners have been notified about it.",
|
||||
color=0xBEBEFE,
|
||||
)
|
||||
)
|
||||
|
||||
app_owner = (await self.bot.application_info()).owner
|
||||
await app_owner.send(
|
||||
embed=discord.Embed(
|
||||
title="New Feedback",
|
||||
description=f"{interaction.user} (<@{interaction.user.id}>) has submitted a new feedback:\n```\n{feedback_form.answer}\n```",
|
||||
color=0xBEBEFE,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
async def setup(bot) -> None:
|
||||
await bot.add_cog(Feedback(bot))
|
||||
Reference in New Issue
Block a user