1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
import discord
from discord import app_commands
from discord.ext import commands
from global_variables import BOT_COLOR, BUG_CHANNEL_ID, FEEDBACK_CHANNEL_ID
class BugReport(discord.ui.Modal, title="Report a bug"):
def __init__(self, bot):
super().__init__()
self.bot = bot
name = discord.ui.TextInput(
label="Discord username",
placeholder="EX: itsmefreddy01...",
)
command = discord.ui.TextInput(
label="Command with error", placeholder="EX: skip...", required=True
)
report = discord.ui.TextInput(
label="A detailed report of the bug",
style=discord.TextStyle.long,
placeholder="Type your report here...",
required=True,
max_length=500,
)
async def on_submit(self, interaction: discord.Interaction):
await interaction.response.send_message(
f"Thanks for your bug report. We will get back to you as soon as possible",
ephemeral=True,
)
channel = self.bot.get_channel(BUG_CHANNEL_ID)
embed = discord.Embed(
title="Bug Report",
description=f"Submitted by {self.name} (<@{interaction.user.id}>)",
color=BOT_COLOR,
)
embed.add_field(
name="Command with issue:", value=f"{self.command}", inline=False
)
embed.add_field(name="Report:", value=f"{self.report}", inline=False)
await channel.send(embed=embed)
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)
class Modals(commands.Cog):
def __init__(self, bot):
self.bot = bot
@app_commands.command()
async def bug(self, interaction: discord.Interaction):
"Send a bug report to the developer"
await interaction.response.send_modal(BugReport(self.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))
|