Exemple #1
0
async def _admin_help(message: Message, channel: TextChannel) -> None:
    """
    Sends help message for admins via dm.
    """
    # Initialize attributes of message
    guild: Guild = message.guild
    member: Member = message.author

    prefix = appearance.get_prefix(guild.id)

    # Setup embed content
    embed: Embed = Embed()
    embed.title = 'Admin Commands'

    # Add fields for commands
    for cmd in description.commands:
        if cmd.admin_only and cmd.in_help(guild):
            embed.add_field(name='`' + prefix + cmd.syntax + '`',
                            value=cmd.description,
                            inline=False)

    # Setup embed style
    embed.colour = appearance.get_color(guild.id)
    embed.set_footer(
        text=
        f'{prefix}help <command> for detailed information | <> Required  |  () Optional',
        icon_url=member.avatar_url)
    # Send direct message or in channel if dm is forbidden
    try:
        await member.send(embed=embed)
    except Forbidden:
        await channel.send(embed=embed)
Exemple #2
0
async def invite_command(message: Message) -> None:
    """
    Sends server invite messages.
    :param message: Message that executed the command
    :return: None
    """
    # Initialize attributes of message
    channel: TextChannel = message.channel
    guild: Guild = message.guild
    member: Member = message.author

    prefix = appearance.get_prefix(guild.id)

    # Fetch invite or create new one
    server_invite: Invite = await channel.create_invite(
        reason='Server invite by fryselBot', unique=False)

    # Setup embed content
    embed: Embed = Embed()
    embed.title = 'Invite - ' + guild.name
    embed.description = server_invite.url

    # Setup embed style
    embed.colour = appearance.get_color(guild.id)
    embed.set_thumbnail(url=guild.icon_url)
    embed.set_footer(text=prefix + 'invite', icon_url=member.avatar_url)

    # Send embed & delete message
    await channel.send(embed=embed)
    await message.delete()
Exemple #3
0
async def cmd_help(message: Message, cmd_name: str) -> None:
    """
    Sends help to a command
    :param message: Message that executed the command
    :param cmd_name: Name of the command
    """
    # Initialize varaibles
    guild: Guild = message.guild
    channel: TextChannel = message.channel
    prefix = appearance.get_prefix(guild.id)

    # Call different help messages depending on permission
    is_suggestion, similar_cmd = description.get_similar_command(cmd_name)

    # Get name with first letter in upper
    name = similar_cmd.name[0].upper() + similar_cmd.name[1:]

    if not is_suggestion:
        embed = Embed(title=f'Help - {name}',
                      description=f'`{prefix}{similar_cmd.syntax}`\n'
                      f'{similar_cmd.get_complete_description()}',
                      colour=appearance.get_color(guild.id))
    else:
        embed = Embed(title=f'Help - {name}',
                      description=f'**Did you mean {similar_cmd.name}?**\n\n'
                      f'`{prefix}{similar_cmd.syntax}`\n'
                      f'{similar_cmd.get_complete_description()}',
                      colour=appearance.get_color(guild.id))

    embed.set_footer(text='Created by frysel  |  <> Required  |  () Optional',
                     icon_url=message.author.avatar_url)
    await channel.send(embed=embed)

    # Delete message
    await util.delete_message(message)
Exemple #4
0
async def setup_page(channel: TextChannel, guild: Guild) -> None:
    """
    Sends a page with all information about the setup of the bot.
    :param guild: Guild of call
    :param channel: TextChannel to send the message to
    """
    # Initialize important values
    guild_prefix = appearance.get_prefix(guild.id)

    # Setup appearance of the embed
    embed: Embed = Embed(title=f'{appearance.bot_name} - Setup',
                         description='Use the following commands or react.')
    embed.colour = appearance.get_color(guild.id)

    # Setup the command descriptions
    embed.add_field(name='Prefix ❗', value=f'`{guild_prefix}setup prefix`', inline=True)
    embed.add_field(name='Color  🟧', value=f'`{guild_prefix}setup color`', inline=True)
    embed.add_field(name='Roles  👥', value=f'`{guild_prefix}setup roles`', inline=True)
    embed.add_field(name='Welcome  👋', value=f'`{guild_prefix}setup welcome`', inline=True)
    embed.add_field(name='Moderation  👮🏽‍♂️', value=f'`{guild_prefix}setup moderation`', inline=True)
    embed.add_field(name='Private Rooms  🔉', value=f'`{guild_prefix}setup private rooms`', inline=True)

    # 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='👥')
    await message.add_reaction(emoji='👋')
    await message.add_reaction(emoji='👮🏽‍♂️')
    await message.add_reaction(emoji='🔉')
Exemple #5
0
async def color_page(channel: TextChannel, guild: Guild) -> None:
    """
    Sends a page with all information about the setup of the color.
    :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 - Color',
                         description='Setup your custom color!')
    embed.colour = appearance.get_color(guild.id)

    # Fetch colorand format to hex color code
    color = hex(appearance.get_color(guild.id))
    color = '#' + str(color)[2:]

    # Setup the fields
    embed.add_field(name='Current Color', value=f'`{color}`', inline=False)
    embed.add_field(
        name='Set Color',
        value=f'`{prefix}{description.get_command("color").syntax}`',
        inline=False)

    embed.add_field(name='Valid Color', value='HEX color code', inline=False)
    embed.add_field(name='Set To Default', value='React with 🟧️', inline=False)

    # Send embed and add reactions
    message = await channel.send(embed=embed)
    await message.add_reaction(emoji='🟧')
Exemple #6
0
async def toggle_welcome_dms(channel: TextChannel, guild: Guild,
                             setup_message: Message) -> None:
    """
    Toggles welcome dms
    :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_dm(guild.id) and not select.welcome_dms(guild.id):
        # The welcome dm has to be set first before enabling welcome dms
        prefix = appearance.get_prefix(guild.id)
        # Send error message and delete it
        error_embed: Embed = Embed(
            title='Welcome DM text has to be set',
            description=f'Set the welcome DM text first using `{prefix}'
            f'{description.get_command("welcome dm").syntax}`',
            colour=appearance.error_color)
        error_message = await channel.send(embed=error_embed)
        await error_message.delete(delay=10)
    else:
        # Toggle the welcome dms
        welcome_sys.toggle_welcome_dm(guild)
        new_status = select.welcome_dms(guild.id)

        # Change status within the embed
        embed = setup_message.embeds[0]
        embed_name = embed.fields[6].name
        if new_status:
            embed.set_field_at(6, name=embed_name, value='✅', inline=True)
            await setup_message.edit(embed=embed)
        else:
            embed.set_field_at(6, name=embed_name, value='❌', inline=True)
            await setup_message.edit(embed=embed)
Exemple #7
0
async def prefix_page(channel: TextChannel, guild: Guild) -> None:
    """
    Sends a page with all information about the setup of the prefix.
    :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 - Prefix',
                         description='Setup your custom prefix!')
    embed.colour = appearance.get_color(guild.id)

    # Setup the fields
    embed.add_field(name='Current Prefix', value=f'`{prefix}`', inline=False)
    embed.add_field(
        name='Set Prefix',
        value=f'`{prefix}{description.get_command("prefix").syntax}`',
        inline=False)

    embed.add_field(name='Valid Prefix',
                    value='A single character.',
                    inline=False)
    embed.add_field(name='Set To Default', value='React with ❗️', inline=False)

    # Send embed and add reactions
    message = await channel.send(embed=embed)
    await message.add_reaction(emoji='❗')
Exemple #8
0
async def roles_page(channel: TextChannel, guild: Guild) -> None:
    """
    Sends a page with all information about the setup of roles.
    :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 - Roles',
                         description='Setup the roles!',
                         colour=appearance.get_color(guild.id))

    # Get existing roles
    admin_roles = '\n'.join(
        map(lambda r: r.mention, roles.get_admin_roles(guild)))
    moderator_roles = '\n'.join(
        map(lambda r: r.mention, roles.get_moderator_roles(guild)))
    # support_roles = '\n'.join(map(lambda r: r.mention, roles.get_support_roles(guild)))
    auto_roles = '\n'.join(
        map(lambda r: r.mention, roles.get_auto_roles(guild)))

    # Add information about the roles already existing to embed
    if admin_roles:
        embed.add_field(name='Admin Roles', value=admin_roles, inline=True)
    if moderator_roles:
        embed.add_field(name='Moderator Roles',
                        value=moderator_roles,
                        inline=True)
    # if support_roles:
    #     embed.add_field(name='Support Roles', value=support_roles, inline=True)
    if auto_roles:
        embed.add_field(name='Autoroles', value=auto_roles, inline=True)

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

    # Add information about the commands
    embed.add_field(
        name='Add Roles',
        value=f'`{prefix}{description.get_command("roles add").syntax}`'
        f'\nThe type is either *admin*, *moderator* or *autorole*.',
        inline=False)
    embed.add_field(
        name='Remove Roles',
        value=f'`{prefix}{description.get_command("roles remove").syntax}`'
        f'\nThe type is either *admin*, *moderator* or *autorole*.',
        inline=False)

    await channel.send(embed=embed)
Exemple #9
0
async def arguments_error(ctx: Context, cmd: Command) -> None:
    """
    Error message for the case f arguments were missing when calling an command.
    Gives instructions how to call the command.
    :param ctx: Context of error
    :param cmd: Command that was used
    """
    # Send error message and delete it after some time
    prefix = appearance.get_prefix(ctx.guild.id)
    error_message = await ctx.send(embed=Embed(
        title='Invalid Arguments',
        description=f'Use `{prefix}{cmd.syntax}`\n{cmd.args_description}',
        colour=appearance.error_color))
    await error_message.delete(delay=15)
Exemple #10
0
async def _member_help(message: Message) -> None:
    """
    Sends help message for members in the text channel.
    :param message: Message that executed the command
    """

    # Initialize attributes of message
    channel: TextChannel = message.channel
    guild: Guild = message.guild
    member: Member = message.author

    prefix = appearance.get_prefix(guild.id)

    # Setup embed content
    embed: Embed = Embed()
    embed.title = 'Commands - ' + appearance.bot_name

    # Add fields for commands
    for cmd in description.commands:
        if cmd.member_cmd() and cmd.in_help(guild):
            embed.add_field(name='`' + prefix + cmd.syntax + '`',
                            value=cmd.description,
                            inline=False)

    # Add fields for other bot functions
    cpr_channel: VoiceChannel = private_rooms.get_cpr_channel(guild)
    if cpr_channel:
        settings_channel: TextChannel = private_rooms.get_settings_channel(
            guild)
        embed.add_field(name='\u200b', value='\u200b', inline=False)
        embed.add_field(
            name='Private Rooms',
            value=f'• Join `{cpr_channel.name}` to create a private Room\n'
            f'• Adjust the settings in {settings_channel.mention}',
            inline=False)

    # Setup embed style
    embed.colour = appearance.get_color(guild.id)
    embed.set_thumbnail(url=guild.get_member(secret.bot_id).avatar_url)
    embed.set_footer(
        text=
        f'{prefix}help <command> for detailed information | <> Required  |  () Optional',
        icon_url=member.avatar_url)

    # Send message
    await channel.send(embed=embed)
Exemple #11
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='📄')
Exemple #12
0
async def moderation_page(channel: TextChannel, guild: Guild):
    """
    Sends a page with all information about the setup of moderation.
    :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 - Moderation',
                         description='Setup the moderation system!',
                         colour=appearance.get_color(guild.id))

    # Add information about moderation roles
    embed.add_field(name='Set Moderation Roles',
                    value=f'React with 👥',
                    inline=False)

    mod_log: TextChannel = mod.get_mod_log(guild)
    # Add information about the current moderation log
    embed.add_field(name='\u200b', value='\u200b', inline=False)

    embed.add_field(name='Moderation Log',
                    value='• Get notified of mod operations\n'
                    '• Unlock reports',
                    inline=False)
    if mod_log:
        embed.add_field(name='Current Channel',
                        value=mod_log.mention,
                        inline=False)

    # Add information about the commands
    embed.add_field(
        name='Set Moderation Log',
        value=f'`{prefix}{description.get_command("moderation log").syntax}`',
        inline=False)

    # How to deactivate moderation log
    if mod_log:
        embed.add_field(name='Deactivate Moderation Log',
                        value='React with 📪',
                        inline=False)

    # Add information about the warn system
    embed.add_field(name='\u200b', value='\u200b', inline=False)
    embed.add_field(name='Warn Punishment',
                    value=f'• **1 warn:**  20 min mute\n'
                    f'• **3 warns within two weeks:**  2h mute\n'
                    f'• **4 warns within one month:**  24h mute & kick')

    # Add information about mute
    mute_role: Role = await mute.get_mute_role(guild)
    embed.add_field(name='\u200b', value='\u200b', inline=False)
    embed.add_field(
        name='Problems With Mute?',
        value=f'Make sure the position of {mute_role.mention} is high enough.')

    # Send embed
    msg = await channel.send(embed=embed)

    # Add reactions
    await msg.add_reaction('👥')
    if mod_log:
        await msg.add_reaction('📪')
Exemple #13
0
async def get_prefix(_: Bot, message: Message):
    """Returns the prefix for the guild of the message"""
    return appearance.get_prefix(guild_id=message.guild.id)