2023-11-23 16:29:56 +00:00
|
|
|
import disnake
|
|
|
|
from disnake.ext import commands
|
|
|
|
from disnake import TextInputStyle
|
2023-11-25 01:26:27 +00:00
|
|
|
from dotenv import load_dotenv
|
|
|
|
import os
|
|
|
|
|
|
|
|
load_dotenv()
|
|
|
|
|
2023-11-23 16:29:56 +00:00
|
|
|
|
|
|
|
class ApplicationModal(disnake.ui.Modal):
|
|
|
|
def __init__(self):
|
|
|
|
# The details of the modal, and its components
|
|
|
|
components = [
|
|
|
|
disnake.ui.TextInput(
|
|
|
|
label="Username (Minecraft)",
|
|
|
|
placeholder="DraconicDragon3",
|
|
|
|
custom_id="Username",
|
|
|
|
style=TextInputStyle.short,
|
|
|
|
max_length=16,
|
|
|
|
),
|
|
|
|
disnake.ui.TextInput(
|
|
|
|
label="Tell us a bit about yourself",
|
2023-11-25 01:26:27 +00:00
|
|
|
placeholder="Three Sentence Minimum Please!",
|
2023-11-23 16:29:56 +00:00
|
|
|
custom_id="Tell us a bit about yourself",
|
|
|
|
style=TextInputStyle.paragraph,
|
|
|
|
),
|
|
|
|
disnake.ui.TextInput(
|
|
|
|
label="The secret phrase",
|
|
|
|
placeholder="",
|
|
|
|
custom_id="The secret phrase",
|
|
|
|
style=TextInputStyle.short,
|
|
|
|
max_length=32,
|
|
|
|
),
|
|
|
|
]
|
|
|
|
super().__init__(title="Apply to join the server", components=components)
|
|
|
|
|
|
|
|
# The callback received when the user input is completed.
|
|
|
|
async def callback(self, inter: disnake.ModalInteraction):
|
|
|
|
embed_color = 0x00ff00
|
|
|
|
embed_title = "New Application"
|
|
|
|
applicationdenied = False
|
|
|
|
application = inter.text_values.items()
|
|
|
|
for key, value in application:
|
2023-11-25 01:26:27 +00:00
|
|
|
if key == "The secret phrase" and value != os.getenv("PHRASE"):
|
2023-11-23 16:29:56 +00:00
|
|
|
applicationdenied = True
|
|
|
|
embed_color = disnake.Colour.red()
|
|
|
|
embed_title = "Auto-Denied Application"
|
|
|
|
embed = disnake.Embed(title=embed_title, color=embed_color)
|
|
|
|
embed.add_field(
|
|
|
|
name="User",
|
|
|
|
value=f"<@{inter.user.id}> ({inter.user.id})",
|
|
|
|
inline=False,
|
|
|
|
)
|
|
|
|
for key, value in application:
|
|
|
|
embed.add_field(
|
|
|
|
name=key,
|
|
|
|
value=value,
|
|
|
|
inline=False,
|
|
|
|
)
|
|
|
|
if applicationdenied:
|
|
|
|
await inter.response.send_message("Your Application has been denied, you may not reapply", ephemeral=True)
|
2023-11-25 01:26:27 +00:00
|
|
|
await bot.get_channel(int(os.getenv("LOG_CHANNEL"))).send(embed=embed)
|
2023-11-23 16:29:56 +00:00
|
|
|
else:
|
|
|
|
await inter.response.send_message("Your Application has been successfully submitted, you will receive your response eventually", ephemeral=True)
|
2023-11-25 01:26:27 +00:00
|
|
|
await bot.get_channel(int(os.getenv("LOG_CHANNEL"))).send(embed=embed, components=[
|
2023-11-23 16:29:56 +00:00
|
|
|
disnake.ui.Button(label="Approve", style=disnake.ButtonStyle.success, custom_id="Approve"),
|
|
|
|
disnake.ui.Button(label="Deny", style=disnake.ButtonStyle.danger, custom_id="Deny"),
|
|
|
|
],)
|
|
|
|
|
2023-11-25 01:26:27 +00:00
|
|
|
bot = commands.Bot(command_prefix=".", test_guilds=[int(os.getenv("GUILD_ID"))])
|
2023-11-23 16:29:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
@bot.slash_command()
|
|
|
|
async def apply(inter: disnake.AppCmdInter):
|
|
|
|
await inter.response.send_modal(modal=ApplicationModal())
|
|
|
|
|
|
|
|
@bot.listen("on_button_click")
|
|
|
|
async def button_listener(inter: disnake.MessageInteraction):
|
|
|
|
if inter.component.custom_id == "Approve":
|
2023-11-25 01:26:27 +00:00
|
|
|
print(await inter.response.message())
|
|
|
|
await inter.response.edit_message("Status: Whitelisted!", components=[])
|
|
|
|
elif inter.component.custom_id == "Deny":
|
|
|
|
await inter.response.edit_message("Status: Blacklisted!", components=[])
|
2023-11-23 16:29:56 +00:00
|
|
|
|
2023-11-25 01:26:27 +00:00
|
|
|
bot.run(os.getenv("TOKEN"))
|