Remove old prints, fixed bunch of bugs
parent
c578dccefb
commit
4429753729
42
bot.py
42
bot.py
|
@ -29,7 +29,7 @@ async def on_ready():
|
|||
for i in bot.guilds:
|
||||
if str(i.id) not in GuildAppDB.get_all_guilds():
|
||||
GuildAppDB.create_guild(str(i.id), i.name)
|
||||
print(f"entry for {i.id} created")
|
||||
print(f"Entry for {i.id} created")
|
||||
|
||||
@bot.event
|
||||
async def on_guild_join(guild):
|
||||
|
@ -69,9 +69,7 @@ async def create(ctx, application):
|
|||
if len(application) < 40:
|
||||
result = GuildAppDB.add_application_entry(str(ctx.guild.id), application)
|
||||
if result == "success":
|
||||
await ctx.response.send_message(f"Successfully created application: {application}", ephemeral=True) # create a new application, modal with name ask
|
||||
else:
|
||||
print(result)
|
||||
await ctx.response.send_message(f"Successfully created application: {application}\n\nDon't forget to set the response channel!", ephemeral=True) # create a new application, modal with name ask
|
||||
else:
|
||||
await ctx.response.send_message(f"please choose shorter name", ephemeral=True)
|
||||
|
||||
|
@ -82,17 +80,17 @@ async def remove(ctx, application):
|
|||
if result == "success":
|
||||
await ctx.response.send_message(f"Successfully removed application: {application}", ephemeral=True)
|
||||
else:
|
||||
await ctx.response.send_message(f"Application {application} not found")
|
||||
await ctx.response.send_message(f"Application {application} not found", ephemeral=True)
|
||||
|
||||
@commands.has_permissions(administrator=True)
|
||||
@application.command(description="List all applications")
|
||||
async def list(ctx):
|
||||
applications = GuildAppDB.get_applications(str(ctx.guild.id))
|
||||
print(applications)
|
||||
embed = discord.Embed()
|
||||
for i in applications:
|
||||
embed.add_field(name=i, value="", inline=False)
|
||||
await ctx.response.send_message(embed=embed)
|
||||
embed = discord.Embed(title="**List of applications**")
|
||||
embed.set_footer(text="Made by @anorak01", icon_url="https://cdn.discordapp.com/avatars/269164865480949760/a1af9962da20d5ddaa136043cf45d015?size=1024")
|
||||
for i, app in enumerate(applications):
|
||||
embed.add_field(value=f"**{i+1}. {app}**", name="", inline=False)
|
||||
await ctx.response.send_message(embed=embed, ephemeral=True)
|
||||
|
||||
@commands.has_permissions(administrator=True)
|
||||
@application.command(description="Opens editor for selected application")
|
||||
|
@ -148,7 +146,6 @@ class SelectResponseChannelView(discord.ui.View):
|
|||
)
|
||||
async def select_callback(self, select, interaction: discord.Interaction):
|
||||
self.disable_all_items()
|
||||
print(select.values[0].id)
|
||||
GuildAppDB.set_response_channel(interaction.guild.id, )
|
||||
await interaction.response.edit_message(content=f"Selected channel: {select.values[0].mention}", view=None)
|
||||
|
||||
|
@ -164,7 +161,7 @@ class SelectApplicationOptionsRespChannel(discord.ui.Select):
|
|||
async def callback(self, interaction: discord.Interaction):
|
||||
self.disabled = True
|
||||
view = discord.ui.View()
|
||||
options = SelectResponseChannel(select_type=discord.ComponentType.channel_select, channel_types=[discord.ChannelType.text], max_values=1)
|
||||
options = SelectResponseChannel(select_type=discord.ComponentType.channel_select, channel_types=[discord.ChannelType.text], max_values=1, placeholder="Select channel")
|
||||
options.set_app_name(self.values[0])
|
||||
view.add_item(options)
|
||||
await interaction.response.edit_message(view=view)
|
||||
|
@ -191,7 +188,6 @@ class ApplicationEditorView(discord.ui.View):
|
|||
row=0
|
||||
)
|
||||
async def add_question(self, button: discord.ui.Button, interaction: discord.Interaction):
|
||||
print("add question")
|
||||
modal = AddQuestionModal(self.application_name)
|
||||
await interaction.response.send_modal(modal)
|
||||
|
||||
|
@ -202,7 +198,6 @@ class ApplicationEditorView(discord.ui.View):
|
|||
row=0
|
||||
)
|
||||
async def remove_question(self, button, interaction: discord.Interaction):
|
||||
print("remove question")
|
||||
view = ApplicationEditorView(str(interaction.guild.id), self.application_name)
|
||||
options = RemoveQuestionSelect(max_values=1, placeholder="Select question to remove")
|
||||
options.set_app_name(self.application_name)
|
||||
|
@ -219,7 +214,6 @@ class ApplicationEditorView(discord.ui.View):
|
|||
row=0
|
||||
)
|
||||
async def edit_question(self, button, interaction: discord.Interaction):
|
||||
print("edit question")
|
||||
view = ApplicationEditorView(str(interaction.guild.id), self.application_name)
|
||||
options = EditQuestionSelect(max_values=1, placeholder="Select question to edit")
|
||||
options.set_app_name(self.application_name)
|
||||
|
@ -236,7 +230,6 @@ class ApplicationEditorView(discord.ui.View):
|
|||
row=0
|
||||
)
|
||||
async def move_question(self, button, interaction: discord.Interaction):
|
||||
print("move question")
|
||||
view = ApplicationEditorView(str(interaction.guild.id), self.application_name)
|
||||
options = MoveQuestionSelect(max_values=1, placeholder="Select question to move")
|
||||
options.set_app_name(self.application_name)
|
||||
|
@ -339,14 +332,15 @@ class ApplicationStartButtonView(discord.ui.View):
|
|||
)
|
||||
async def start_app(self, button: discord.ui.Button, interaction: discord.Interaction):
|
||||
app_name, guild_id = StartButtonDB.get_start_msg(interaction.message.id)
|
||||
print(app_name)
|
||||
print(guild_id)
|
||||
|
||||
questions, max_questions=GuildAppDB.get_questions(guild_id, app_name)
|
||||
if questions == "error on get questions: application not found":
|
||||
await interaction.response.send_message(content="Application no longer exists", ephemeral=True)
|
||||
return
|
||||
response_channel = GuildAppDB.get_response_channel(guild_id, app_name)
|
||||
|
||||
user = await interaction.user.create_dm()
|
||||
embedd = discord.Embed(title=f'CreaTopia Application', description="Hey! Your application has started. You have 300 seconds to complete it.")
|
||||
embedd = discord.Embed(title=f'{interaction.guild.name} application: {app_name}', description="Hey! Your application has started. You have 300 seconds to complete it.")
|
||||
embedd.add_field(value=f'You can cancel the application by answering "cancel" to any of the questions', name="", inline=False)
|
||||
embedd.set_footer(text="Made by @anorak01", icon_url="https://cdn.discordapp.com/avatars/269164865480949760/a1af9962da20d5ddaa136043cf45d015?size=1024")
|
||||
|
||||
|
@ -385,7 +379,7 @@ class ApplicationStartButtonView(discord.ui.View):
|
|||
json.dump(data, f)
|
||||
|
||||
channel = bot.get_channel(int(response_channel))
|
||||
embed = discord.Embed(title='Application: ' + interaction.user.display_name)
|
||||
embed = discord.Embed(title=f"Application: {app_name}\nUser: {interaction.user.display_name}")
|
||||
for i in range(0, max_questions):
|
||||
embed.add_field(name=f'{questions[i]}', value=application[f'question{i}'], inline=False)
|
||||
embed.set_footer(text=f"Applicant ID: {interaction.user.id}")
|
||||
|
@ -394,8 +388,6 @@ class ApplicationStartButtonView(discord.ui.View):
|
|||
|
||||
msg = await channel.send(embed=embed, view=appView)
|
||||
|
||||
print(msg.id)
|
||||
|
||||
MessageDB.add_application_msg(msg.id, interaction.user.id, interaction.guild.id)
|
||||
|
||||
await user.send('Thank you for applying!')
|
||||
|
@ -448,11 +440,11 @@ class ApplicationModal(discord.ui.Modal):
|
|||
user_id, guild_id = MessageDB.get_application_msg(msg_id)
|
||||
if self.action == "acc":
|
||||
user = await bot.get_user(user_id).create_dm()
|
||||
await user.send(f"You have been accepted to the CreatTopia Minecraft server!")
|
||||
await user.send(f"Your application has been accepted!")
|
||||
await user.send(f"Reason: {reason}")
|
||||
await interaction.response.send_message(content="Application accepted", ephemeral=True)
|
||||
role = get(interaction.message.guild.roles, name="CreatTopian")
|
||||
await discord.utils.get(interaction.message.guild.members, id=int(user_id)).add_roles(role)
|
||||
#await discord.utils.get(interaction.message.guild.members, id=int(user_id)).add_roles(role)
|
||||
emb = interaction.message.embeds[0]
|
||||
emb.colour = discord.Colour.green()
|
||||
embed = discord.Embed(title='Accepted')
|
||||
|
@ -464,7 +456,7 @@ class ApplicationModal(discord.ui.Modal):
|
|||
await interaction.followup.edit_message(message_id = interaction.message.id, view = view)
|
||||
if self.action == "dec":
|
||||
user = await bot.get_user(user_id).create_dm()
|
||||
await user.send(f"You have been declined access to the CreatTopia Minecraft server.")
|
||||
await user.send(f"Your application has been declined.")
|
||||
await user.send(f"Reason: {reason}")
|
||||
await interaction.response.send_message(content="Application declined", ephemeral=True)
|
||||
emb = interaction.message.embeds[0]
|
||||
|
|
Loading…
Reference in New Issue