Add feedback command
This commit is contained in:
parent
7caf3ed074
commit
e0b75e7de5
44
code/cogs/feedback.py
Normal file
44
code/cogs/feedback.py
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import discord
|
||||||
|
|
||||||
|
from global_variables import FEEDBACK_CHANNEL_ID, BOT_COLOR
|
||||||
|
|
||||||
|
|
||||||
|
class FeedbackForm(discord.ui.Modal, title="Give feedback about the bot"):
|
||||||
|
def __init__(self, bot):
|
||||||
|
super().__init__()
|
||||||
|
self.bot = bot
|
||||||
|
|
||||||
|
name = discord.ui.TextInput(
|
||||||
|
label="Discord username",
|
||||||
|
placeholder="EX: itsmefreddy01...",
|
||||||
|
)
|
||||||
|
positive = discord.ui.TextInput(
|
||||||
|
label="What do you like about the bot?",
|
||||||
|
style=discord.TextStyle.long,
|
||||||
|
placeholder="Your response here...",
|
||||||
|
required=True,
|
||||||
|
max_length=500,
|
||||||
|
)
|
||||||
|
negative = discord.ui.TextInput(
|
||||||
|
label="What should be changed about the bot?",
|
||||||
|
style=discord.TextStyle.long,
|
||||||
|
placeholder="Your response here...",
|
||||||
|
required=True,
|
||||||
|
max_length=500,
|
||||||
|
)
|
||||||
|
|
||||||
|
async def on_submit(self, interaction: discord.Interaction):
|
||||||
|
await interaction.response.send_message(
|
||||||
|
f"Thank you for your feedback. We love hearing from users!", ephemeral=True
|
||||||
|
)
|
||||||
|
channel = self.bot.get_channel(FEEDBACK_CHANNEL_ID)
|
||||||
|
|
||||||
|
embed = discord.Embed(
|
||||||
|
title="Bot Feedback",
|
||||||
|
description=f"Submitted by {self.name} (<@{interaction.user.id}>)",
|
||||||
|
color=BOT_COLOR,
|
||||||
|
)
|
||||||
|
embed.add_field(name="Positive:", value=f"{self.positive}", inline=False)
|
||||||
|
embed.add_field(name="Negative:", value=f"{self.negative}", inline=False)
|
||||||
|
|
||||||
|
await channel.send(embed=embed)
|
19
code/cogs/modals.py
Normal file
19
code/cogs/modals.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import discord
|
||||||
|
from discord import app_commands
|
||||||
|
from discord.ext import commands
|
||||||
|
|
||||||
|
from feedback import FeedbackForm
|
||||||
|
|
||||||
|
|
||||||
|
class Modals(commands.Cog):
|
||||||
|
def __init__(self, bot):
|
||||||
|
self.bot = bot
|
||||||
|
|
||||||
|
@app_commands.command()
|
||||||
|
async def feedback(self, interaction: discord.Interaction):
|
||||||
|
"Send bot feeback to the developer"
|
||||||
|
await interaction.response.send_modal(FeedbackForm(self.bot))
|
||||||
|
|
||||||
|
|
||||||
|
async def setup(bot):
|
||||||
|
await bot.add_cog(Modals(bot))
|
@ -46,6 +46,7 @@ config.read_string(file_contents)
|
|||||||
|
|
||||||
BOT_TOKEN = config["BOT_INFO"]["TOKEN"]
|
BOT_TOKEN = config["BOT_INFO"]["TOKEN"]
|
||||||
BOT_COLOR = discord.Color(int((config["BOT_INFO"]["BOT_COLOR"]).replace("#", ""), 16))
|
BOT_COLOR = discord.Color(int((config["BOT_INFO"]["BOT_COLOR"]).replace("#", ""), 16))
|
||||||
|
FEEDBACK_CHANNEL_ID = int(config["BOT_INFO"]["FEEDBACK_CHANNEL_ID"])
|
||||||
|
|
||||||
LAVALINK_HOST = config["LAVALINK"]["HOST"]
|
LAVALINK_HOST = config["LAVALINK"]["HOST"]
|
||||||
LAVALINK_PORT = config["LAVALINK"]["PORT"]
|
LAVALINK_PORT = config["LAVALINK"]["PORT"]
|
||||||
|
@ -29,6 +29,12 @@ def validate_config(file_contents):
|
|||||||
) and not bool(re.match(pattern_2, config["BOT_INFO"]["BOT_COLOR"])):
|
) and not bool(re.match(pattern_2, config["BOT_INFO"]["BOT_COLOR"])):
|
||||||
LOG.critical("BOT_COLOR is not a valid hex color.")
|
LOG.critical("BOT_COLOR is not a valid hex color.")
|
||||||
errors += 1
|
errors += 1
|
||||||
|
# Validate FEEDBACK_CHANNEL_ID
|
||||||
|
if not config["BOT_INFO"]["FEEDBACK_CHANNEL_ID"]:
|
||||||
|
LOG.critical("FEEDBACK_CHANNEL_ID has not been set.")
|
||||||
|
|
||||||
|
elif len(config["BOT_INFO"]["FEEDBACK_CHANNEL_ID"]) != 19:
|
||||||
|
LOG.critical("FEEDBACK_CHANNEL_ID is not a valid Discord channel ID.")
|
||||||
|
|
||||||
# Validate LAVALINK
|
# Validate LAVALINK
|
||||||
# Validate HOST
|
# Validate HOST
|
||||||
@ -62,10 +68,7 @@ def create_config():
|
|||||||
|
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config["BOT_INFO"] = {
|
config["BOT_INFO"] = {"TOKEN": "", "BOT_COLOR": "", "FEEDBACK_CHANNEL_ID": ""}
|
||||||
"TOKEN": "",
|
|
||||||
"BOT_COLOR": "",
|
|
||||||
}
|
|
||||||
|
|
||||||
config["LAVALINK"] = {"HOST": "", "PORT": "", "PASSWORD": ""}
|
config["LAVALINK"] = {"HOST": "", "PORT": "", "PASSWORD": ""}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
[BOT_INFO]
|
[BOT_INFO]
|
||||||
token =
|
token =
|
||||||
bot_color =
|
bot_color =
|
||||||
|
feedback_channel_id =
|
||||||
|
|
||||||
[LAVALINK]
|
[LAVALINK]
|
||||||
host =
|
host =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user