2023-03-12 12:13:30 +01:00
|
|
|
import asyncio
|
2023-03-12 18:02:28 +01:00
|
|
|
from typing import Union, List
|
2023-03-12 12:13:30 +01:00
|
|
|
from datetime import timedelta
|
|
|
|
|
from copy import copy
|
|
|
|
|
import contextlib
|
|
|
|
|
import discord
|
|
|
|
|
|
2023-03-12 17:49:13 +01:00
|
|
|
|
2023-03-12 12:13:30 +01:00
|
|
|
from redbot.core import Config, checks, commands
|
|
|
|
|
from redbot.core.utils import AsyncIter
|
|
|
|
|
from redbot.core.utils.chat_formatting import pagify, box
|
|
|
|
|
from redbot.core.utils.antispam import AntiSpam
|
|
|
|
|
from redbot.core.bot import Red
|
|
|
|
|
from redbot.core.utils.predicates import MessagePredicate
|
|
|
|
|
|
2023-03-12 21:26:26 +01:00
|
|
|
application_channel_id = 1023172488143839252
|
2023-03-12 12:13:30 +01:00
|
|
|
|
|
|
|
|
class Recruitment(commands.Cog):
|
2023-03-12 21:26:26 +01:00
|
|
|
"""A cog that lets a user send a membership application.
|
2023-03-12 12:13:30 +01:00
|
|
|
|
2023-03-12 21:26:26 +01:00
|
|
|
Users can open an application using `[!]apply`. These are then sent
|
2023-03-12 12:13:30 +01:00
|
|
|
to a channel in the server for staff, and the application creator
|
|
|
|
|
gets a DM. Both can be used to communicate.
|
|
|
|
|
"""
|
2023-03-12 21:26:26 +01:00
|
|
|
|
|
|
|
|
def __init__(self, bot):
|
2023-03-12 12:13:30 +01:00
|
|
|
self.bot = bot
|
2023-03-12 21:26:26 +01:00
|
|
|
self.message: str = ''
|
|
|
|
|
self.active = True
|
2023-03-12 17:29:05 +01:00
|
|
|
|
2023-03-12 12:13:30 +01:00
|
|
|
|
2023-03-12 21:26:26 +01:00
|
|
|
|
|
|
|
|
@commands.group(name="apply", usage="[text]", invoke_without_command=True)
|
|
|
|
|
async def apply(self, ctx: commands.Context, *, _apply: str = ""):
|
2023-03-12 12:13:30 +01:00
|
|
|
"""Send an application.
|
|
|
|
|
|
2023-03-12 21:26:26 +01:00
|
|
|
Use without arguments for an interactive application creation flow, or do
|
2023-03-12 12:13:30 +01:00
|
|
|
`[p]apply [text]` to use it non-interactively.
|
|
|
|
|
"""
|
|
|
|
|
author = ctx.author
|
|
|
|
|
|
2023-03-12 21:26:26 +01:00
|
|
|
# If there is no text argument, use an interactive flow
|
|
|
|
|
if not _apply:
|
|
|
|
|
# Send a DM to the author to initiate the application
|
|
|
|
|
await author.send("Please answer the following questions to complete your application.")
|
|
|
|
|
questions = ["What's your name?", "What's your age?", "Why do you want to join our community?"]
|
|
|
|
|
answers = []
|
|
|
|
|
|
|
|
|
|
# Ask the user the questions
|
|
|
|
|
for question in questions:
|
|
|
|
|
await author.send(question)
|
|
|
|
|
# Wait for the user to respond
|
|
|
|
|
answer = await self.bot.wait_for(
|
|
|
|
|
"message", check=lambda m: m.author == author and m.guild is None
|
2023-03-12 12:13:30 +01:00
|
|
|
)
|
2023-03-12 21:26:26 +01:00
|
|
|
answers.append(answer.content)
|
2023-03-12 12:13:30 +01:00
|
|
|
|
2023-03-12 21:26:26 +01:00
|
|
|
# Combine the answers into a single message and send to the application channel
|
|
|
|
|
application_text = "\n".join([f"{question}: {answer}" for question, answer in zip(questions, answers)])
|
|
|
|
|
application_channel = self.bot.get_channel(application_channel_id)
|
|
|
|
|
await application_channel.send(application_text)
|
2023-03-12 12:13:30 +01:00
|
|
|
|
2023-03-12 21:26:26 +01:00
|
|
|
# Send a confirmation message to the author
|
|
|
|
|
await author.send("Thank you for submitting your application!")
|
|
|
|
|
else:
|
|
|
|
|
# If there is a text argument, use a non-interactive flow
|
|
|
|
|
application_channel = self.bot.get_channel(application_channel_id)
|
|
|
|
|
await application_channel.send(_apply)
|
|
|
|
|
await author.send("Thank you for submitting your application!")
|