Example #1
0
    async def serverinfo(self, ctx):
        if ctx.message.guild is None:
            await ctx.send(
                ctx.message.author.display_name +
                ', You can only request for server info within a server!')
            return

        query.insert_ignore_server(ctx.message.guild.id)
        server_data = query.get_server(ctx.message.guild.id)

        embed = discord.Embed(title=ctx.message.guild.name)
        embed.timestamp = datetime.utcnow()
        embed.set_thumbnail(url=ctx.message.guild.icon_url)
        embed.colour = discord.Colour(int('ffd300', 16))

        embed.add_field(
            name='Nickname sync',
            value=str(server_data[ctx.message.guild.id]['nickname_sync'] == 1)
            +
            ' (If true, nicknames will be set automatically based on the sync source)',
            inline=False)
        embed.add_field(
            name='Role sync',
            value=str(server_data[ctx.message.guild.id]['role_sync'] == 1) +
            ' (If true, roles will be set automatically based on the sync source)',
            inline=False)
        if server_data[ctx.message.guild.id]['nickname_sync'] or server_data[
                ctx.message.guild.id]['role_sync']:
            embed.add_field(
                name='Sync source',
                value=server_data[ctx.message.guild.id]['sync_source'],
                inline=False)
        embed.add_field(
            name='Join message',
            value=str(server_data[ctx.message.guild.id]['join_message'] == 1) +
            ' (If true, bot will send a default join message whenever a new member joins your server)',
            inline=False)
        prefix = await self.bot.command_prefix(self.bot, ctx.message)
        embed.add_field(name='Server prefix', value=prefix, inline=False)
        clist = ''
        for text_channel in ctx.message.guild.text_channels:
            if query.exists('subscriptions_contests', 'channel_id',
                            text_channel.id):
                clist += text_channel.mention + '\n'
        embed.add_field(name='Contest notification channel(s)',
                        value='None' if clist == '' else clist,
                        inline=False)
        await ctx.send(ctx.message.author.display_name +
                       ', Here is your requested info!',
                       embed=embed)
Example #2
0
async def setprefix(ctx, fix: str = None):
    if fix is not None and len(fix) > 255:
        await ctx.send(
            ctx.message.author.display_name +
            ', Sorry, prefix is too long (maximum of 255 characters)')
    elif fix is not None and ('"' in fix or '\'' in fix):
        await ctx.send(
            ctx.message.author.display_name +
            ', Sorry, prefix cannot contain quotation charaters `\'` or `"`')
    elif fix is not None and (' ' in fix or '\n' in fix or '\r' in fix
                              or '\t' in fix):
        await ctx.send(ctx.message.author.display_name +
                       ', Sorry, prefix cannot contain any whitespace')
    elif fix is not None and '\\' in fix:
        await ctx.send(
            ctx.message.author.display_name +
            ', Sorry, prefix cannot contain contain backslash characters `\`')
    elif fix is not None and not is_ascii(fix):
        await ctx.send(ctx.message.author.display_name +
                       ', Sorry, prefix cannot contain non-ASCII characters')
    else:
        default = fix is None
        if default:
            fix = prefix
        previous_prefix = custom_prefixes.get(ctx.message.guild.id, prefix)
        custom_prefixes[ctx.message.guild.id] = fix
        query.insert_ignore_server(ctx.message.guild.id)
        query.update_server_prefix(ctx.message.guild.id, fix)
        if default:
            await ctx.send(
                ctx.message.author.display_name +
                ', No prefix given, defaulting to `%s`. Server prefix changed from `%s` to `%s`'
                % (prefix, previous_prefix, fix))
        else:
            await ctx.send(ctx.message.author.display_name +
                           ', Server prefix changed from `%s` to `%s`' %
                           (previous_prefix, fix))
            await changenick(ctx, ctx.message.guild.get_member(bot.user.id),
                             fix)
Example #3
0
 def check_existing_server(self, server):
     query.insert_ignore_server(server.id)
Example #4
0
async def prefix_from_guild(guild):
    if guild:
        query.insert_ignore_server(guild.id)
        custom = query.get_prefix(guild.id)
        return prefix if custom is None else custom
    return prefix
Example #5
0
async def determine_prefix(bot, message):
    guild = message.guild
    if guild:
        query.insert_ignore_server(guild.id)
        return custom_prefixes.get(guild.id, prefix)
    return prefix