Exemple #1
0
async def welcome_message(member: Member) -> None:
    """
    Sends welcome message for member
    :param member: Member joined
    """
    guild: Guild = member.guild

    if not select.welcome_messages(guild.id):
        # Only send welcome messages when they are enabled on guild
        return

    # Get welcome channel
    welcome_channel: TextChannel = guild.get_channel(
        select.welcome_channel_id(guild.id))

    welcome_messages = [
        '{} joined. You must construct additional pylons.',
        'Never gonna give {} up. Never let {} down!',
        'Hey! Listen! {} has joined!',
        'Ha! {} has joined! You activated my trap card!',
        "We've been expecting you, {}.",
        "It's dangerous to go alone, take {}!", 'Swoooosh. {} just landed.',
        'Brace yourselves. {} just joined the Server.', 'A wild {} appeared.'
    ]

    # Setup embed
    embed: Embed = Embed()
    embed.description = random.choice(welcome_messages).replace(
        '{}', member.mention)

    # Setup embed style
    embed.colour = appearance.get_color(guild.id)

    # Send embed to welcome_channel
    await welcome_channel.send(embed=embed)
Exemple #2
0
async def leave_message(member: Member) -> None:
    """
    Sends leave message for member
    :param member: Member left
    """
    guild: Guild = member.guild

    if not select.leave_messages(guild.id):
        # Only send leave messages when they are enabled on guild
        return

    # Get welcome channel
    welcome_channel: TextChannel = guild.get_channel(
        select.welcome_channel_id(guild.id))

    welcome_messages = ["{} left, the party's over."]

    # Setup embed
    embed: Embed = Embed()
    embed.description = random.choice(welcome_messages).replace(
        '{}', member.mention)

    # Setup embed style
    embed.colour = appearance.get_color(guild.id)

    # Send embed to welcome_channel
    await welcome_channel.send(embed=embed)
Exemple #3
0
async def toggle_leave_messages(channel: TextChannel, guild: Guild,
                                setup_message: Message) -> None:
    """
    Toggles leave messages
    :param channel: Channel of the call
    :param guild: Guild of the call
    :param setup_message: The message where the reaction was edited
    """
    if not select.welcome_channel_id(guild.id) and not select.leave_messages(
            guild.id):
        # The welcome_channel has to be set first before enabling leave messages
        prefix = appearance.get_prefix(guild.id)
        # Send error message and delete it
        error_embed: Embed = Embed(
            title='Welcome channel has to be set',
            description=f'Set the welcome channel first using `{prefix}'
            f'{description.get_command("welcome channel").syntax}`',
            colour=appearance.error_color)
        error_message = await channel.send(embed=error_embed)
        await error_message.delete(delay=10)
    else:
        # Toggle the leave messages
        welcome_sys.toggle_leave(guild)
        new_status = select.leave_messages(guild.id)

        # Change status within the embed
        embed = setup_message.embeds[0]
        embed_name = embed.fields[3].name
        if new_status:
            embed.set_field_at(3, name=embed_name, value='✅', inline=True)
            await setup_message.edit(embed=embed)
        else:
            embed.set_field_at(3, name=embed_name, value='❌', inline=True)
            await setup_message.edit(embed=embed)
Exemple #4
0
async def welcome_page(channel: TextChannel, guild: Guild) -> None:
    """
    Sends a page with all information about the setup of the welcome system.
    :param guild: Guild of call
    :param channel: TextChannel to send the message to
    """

    # Initialize important values
    prefix = appearance.get_prefix(guild.id)

    # Setup appearance of the embed
    embed: Embed = Embed(title=f'{appearance.bot_name} Setup - Welcome',
                         description='Setup the welcome system!')
    embed.colour = appearance.get_color(guild.id)

    # Emojis whether welcome/leave is setup
    welcome_dm_emoji = '✅' if select.welcome_dms(guild.id) else '❌'
    welcome_emoji = '✅' if select.welcome_messages(guild.id) else '❌'
    leave_emoji = '✅' if select.leave_messages(guild.id) else '❌'

    welcome_channel: TextChannel = guild.get_channel(
        select.welcome_channel_id(guild.id))
    welcome_dm = select.welcome_dm(guild.id)

    # Setup the fields
    embed.add_field(name='Welcome Messages Set Up?',
                    value=welcome_emoji,
                    inline=True)
    embed.add_field(name='Toggle Welcome Messages',
                    value='React with 👋',
                    inline=True)

    embed.add_field(name='\u200b', value='\u200b', inline=True)

    embed.add_field(name='Leave Message Set Up?',
                    value=leave_emoji,
                    inline=True)
    embed.add_field(name='Toggle Leave Messages',
                    value='React with 🚶‍♂️',
                    inline=True)

    embed.add_field(name='\u200b', value='\u200b', inline=True)

    embed.add_field(name='Welcome DMs Set Up?',
                    value=welcome_dm_emoji,
                    inline=True)
    embed.add_field(name='Toggle Welcome DMs',
                    value='React with 📩',
                    inline=True)

    embed.add_field(name='\u200b', value='\u200b', inline=True)
    embed.add_field(name='\u200b', value='\u200b', inline=False)

    if welcome_channel:
        embed.add_field(name='Welcome Channel',
                        value=welcome_channel.mention,
                        inline=True)

    embed.add_field(
        name='Set Welcome Channel',
        value=f'`{prefix}{description.get_command("welcome channel").syntax}`',
        inline=False)

    embed.add_field(name='\u200b', value='\u200b', inline=False)

    if welcome_dm:
        embed.add_field(name='Preview Welcome DM',
                        value='React with 📄',
                        inline=False)

    embed.add_field(
        name='Set Welcome DM Text',
        value=f'`{prefix}{description.get_command("welcome dm").syntax}`'
        f"\n'<member>' will be replaced by the name"
        f"\nof the member.",
        inline=False)

    # Send embed and add reactions
    message = await channel.send(embed=embed)

    await message.add_reaction(emoji='👋')
    await message.add_reaction(emoji='🚶‍♂️')
    await message.add_reaction(emoji='📩')
    if welcome_dm:
        await message.add_reaction(emoji='📄')