79 lines
3.2 KiB
Python
79 lines
3.2 KiB
Python
|
import disnake
|
||
|
from disnake.ext import commands
|
||
|
from disnake import TextInputStyle
|
||
|
|
||
|
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",
|
||
|
placeholder="Hi, I'm insert I want to join because...",
|
||
|
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:
|
||
|
if key == "The secret phrase" and value != "REDACTED":
|
||
|
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)
|
||
|
await bot.get_channel(1176963806778359818).send(embed=embed)
|
||
|
else:
|
||
|
await inter.response.send_message("Your Application has been successfully submitted, you will receive your response eventually", ephemeral=True)
|
||
|
await bot.get_channel(1176963806778359818).send(embed=embed, components=[
|
||
|
disnake.ui.Button(label="Approve", style=disnake.ButtonStyle.success, custom_id="Approve"),
|
||
|
disnake.ui.Button(label="Deny", style=disnake.ButtonStyle.danger, custom_id="Deny"),
|
||
|
],)
|
||
|
|
||
|
bot = commands.Bot(command_prefix=".", test_guilds=[699285282276507708])
|
||
|
|
||
|
|
||
|
@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":
|
||
|
await inter.response.send_message("Whitelisted!")
|
||
|
elif inter.component.custom_id == "no":
|
||
|
await inter.response.send_message("Blacklisted!")
|
||
|
|
||
|
bot.run("REDACTED")
|