Exemplo n.º 1
0
    async def on_message(self, message: discord.Message, trigger: str, args: list):
        settings = await self.bot.db.get_guild_settings(message.guild.id)
        if not settings.counters:
            response = create_embed(title='The jar is empty')
        else:
            worth = 25
            author_total = 0
            server_total = 0
            for channel_id, values in settings.counters['nani'].items():
                channel = find(lambda ch: ch.id == int(channel_id), message.guild.text_channels)
                if channel:
                    channel_total = 0
                    for user_id, count in values.items():
                        if int(user_id) == message.author.id:
                            author_total += count
                        if channel.id == message.channel.id:
                            channel_total += count
                        server_total += count

            desc = f"You have contributed ¥{author_total * worth} to the Nani Jar\n" \
                   f"This channel contributed ¥{channel_total * worth} to the Nani Jar\n" \
                   f"There is ¥{server_total * worth} in the Nani Jar"
            response = create_embed(
                title='💴 Nani jar',
                description=desc,
                colour=message.guild.me.colour)
        await message.channel.send(embed=response)
Exemplo n.º 2
0
    async def report(self, ctx, report: str):
        report_channel = self.bot.get_channel(plotvars.reports_channel)
        if report_channel is None:
            description = f"An Error happened on our end: report channel not found. Please report this issue to our support server: {plotvars.support_discord_link}"
            await ctx.send(embed=utils.error_embed(description))
            return
        else:
            title = f"New Bug Report From {ctx.author.name} (user ID: {ctx.author.id})"
            colour = discord.Color.dark_orange()
            await report_channel.send(
                embed=utils.create_embed(title, report, colour))

            await ctx.send(embed=utils.create_embed(
                "Thank you! Your bug report has been sent.", "", colour))
Exemplo n.º 3
0
    async def suggest(self, ctx, suggestion: str):
        suggestion_channel = self.bot.get_channel(plotvars.suggestion_channel)
        if suggestion_channel is None:
            description = f"An Error happened on our end: Suggestion channel not found. Please report this issue to our support server: {plotvars.support_discord_link}"
            await ctx.send(embed=utils.error_embed(description))
            return
        else:
            title = f"New Feature Suggestion From {ctx.author.name} (user ID: {ctx.author.id})"
            colour = discord.Color.dark_orange()
            await suggestion_channel.send(
                embed=utils.create_embed(title, suggestion, colour))

            await ctx.send(embed=utils.create_embed(
                "Thank you! Your feature suggestion has been sent.", "",
                colour))
Exemplo n.º 4
0
    async def removerow(self, ctx, dataset_name:str, row_name:str):
        """Removes a row of data from a user's dataset.

        Args:
            dataset_name (str): Name of the dataset
            row_name (str): Name of the row to remove
        """
        #Get the data
        datadict = await asyncutils.get_data_dictionary(ctx, dataset_name)
        if datadict is None:
            return
        
        values = datadict.get(row_name, None)
        if values is None:
            description=f"Your row name doesn't exist in dataset `{dataset_name}`. Please double-check the names using `/viewdata <dataset_name>` and try again."
            await ctx.send(embed=utils.error_embed(description))
            return

        del datadict[row_name]

        #Write the data to the database
        data_written = await asyncutils.log_data_to_database(ctx, dataset_name, datadict)
        if data_written == False:
            return
        
        title=f"Row `{row_name}` has been deleted from dataset `{dataset_name}`!"
        description=""
        color=discord.Color.green()
        await ctx.send(embed=utils.create_embed(title, description, color))
Exemplo n.º 5
0
    async def setaxisboundaries(self, ctx, dataset_name: str, minimum_x: float,
                                maximum_x: float, minimum_y: float,
                                maximum_y: float):
        """Sets specific axis boundaries (minimums and maximums for x and y) for a specific dataset.

        Args:
            dataset_name (str): Name of the dataset
            minimum_x (float): Minimum X value for the axis
            maximum_x (float): Maximum X value for the axis
            minimum_y (float): Minimum Y value for the axis
            maximum_y (float): Maximum Y value for the axis
        """
        try:
            author = ctx.author
            bounds = [
                float(minimum_x),
                float(maximum_x),
                float(minimum_y),
                float(maximum_y)
            ]
            dbfunc.set_axis_info(author.id, dataset_name, str(bounds))
            title = f"Axis boundaries `{str(bounds)}` have been set for dataset {dataset_name}!"
            description = ""
            colour = discord.Color.green()
            await ctx.send(embed=utils.create_embed(title, description, colour)
                           )
        except:
            description = f"One of your boundary inputs was not a float. Please try again or reference `/help setaxisboundaries` for more information."
            await ctx.send(embed=utils.error_embed(description))
Exemplo n.º 6
0
    async def on_message(self, message: discord.Message, trigger: str, args: list):
        if not args:
            return
        where, what = re.match(rf'{self.bot.prefix}{trigger}\s(\w+)\s?(.+)?', message.content).groups()

        if where in ('g', 'guild'):
            item = message.guild
        else:
            if where in ('cat', 'category'):
                items = message.guild.categories
            elif where in ('ch', 'channel'):
                items = message.guild.channels
            elif where in ('vc', 'voice'):
                items = message.guild.voice_channels
            elif where in ('r', 'role'):
                items = message.guild.roles
            elif where in ('u', 'user'):
                items = message.guild.members
            else:
                return
            item = utils.find(lambda i: i.name.lower() == what.lower(), items)

        if item:
            response = utils.create_embed(
                title=f'{item.name}',
                description=f'{item.id}',
                colour=utils.get_colour(item),
                icon=utils.get_icon(item)
            )
            await message.channel.send(embed=response)
Exemplo n.º 7
0
    async def on_message(self, message: discord.Message, trigger: str, args: list):
        guild = message.author.guild
        settings = await self.bot.db.get_guild_settings(guild.id)

        if trigger == 'underage':
            if not args:
                underage_members = list(filter(lambda m: m,
                                               [utils.find(lambda m: m.id == user_id, guild.members)
                                                for user_id in settings.underage]))
                response = utils.create_embed(
                    title='🐤 Underage users',
                    description='\n'.join([f'- {underage_member.display_name}'
                                           for underage_member in underage_members]),
                    footer='{} total'.format(len(underage_members)),
                    colour=utils.Colours.info
                )
                await message.channel.send(embed=response)
            else:
                users_to_add = self.get_list_of_mentioned_users(message, args)

                for user in users_to_add:
                    if user.id not in settings.underage:
                        action = ('added', 'to')
                        settings.underage.append(user.id)
                    else:
                        action = ('removed', 'from')
                        settings.underage.remove(user.id)
                    await settings.commit()

                    response = utils.create_embed(
                        title='{} has been {} {} underage list.'.format(user.display_name, *action),
                        icon=user.avatar_url,
                        colour=utils.Colours.info
                    )
                    await message.channel.send(embed=response)
        elif trigger == 'underage?':
            if args:
                users_to_check = self.get_list_of_mentioned_users(message, args)
                for user in users_to_check:
                    result = 'in' if user.id in settings.underage else 'not in'
                    response = utils.create_embed(
                        title=f'{user.display_name} is {result} the underage list.',
                        icon=user.avatar_url,
                        colour=utils.Colours.info
                    )
                    await message.channel.send(embed=response)
Exemplo n.º 8
0
 async def on_message(self, message: discord.Message, trigger: str,
                      args: list):
     response = utils.create_embed(
         title='Guild list',
         icon=message.author.guild.me.avatar_url,
         description='\n'.join(
             [f'{guild.name} | {guild.id}' for guild in self.bot.guilds]),
         colour=message.author.guild.me.top_role.colour)
     await message.channel.send(embed=response)
Exemplo n.º 9
0
    async def viewdatasets(self, ctx):
        """Gives the user a list of datasets they currently have.

        """
        author = ctx.author
        title=f'{author.name}\'s datasets:'
        description = dbfunc.get_names_of_datasets(author.id)
        color=discord.Color.orange()
        await ctx.send(embed=utils.create_embed(title=title, description=description, color=color))
Exemplo n.º 10
0
    async def legend(self, ctx, dataset_name: str, legend: str):
        """Sets the legend option for a dataset's plot to on or off.

        Args:
            dataset_name (str): Name of the dataset
            legend (str): Either "on" or "off" to turn the legend feature.
        """
        author = ctx.author
        dbfunc.set_legend(author.id, dataset_name, legend)
        title = f"Successfully set legend setting in dataset {dataset_name} to {legend}!"
        colour = discord.Color.green()
        await ctx.send(embed=utils.create_embed(title, "", colour))
Exemplo n.º 11
0
    async def setplottitle(self, ctx, dataset_name: str, plot_title: str):
        """Sets a plot title for your dataset.

        Args:
            dataset_name (str): Name of the dataset
            plot_title (str): Title of the plot
        """
        author = ctx.author
        dbfunc.set_plot_title(author.id, dataset_name, plot_title)
        title = f"Plot title of `{plot_title}` has been set for dataset {dataset_name}!"
        description = ""
        colour = discord.Color.green()
        await ctx.send(embed=utils.create_embed(title, description, colour))
Exemplo n.º 12
0
    async def on_message(self, message: discord.Message, trigger: str, args: list):
        no_roles = [member
                    for member in message.author.guild.members
                    if len(member.roles) == 1]

        response = utils.create_embed(
            title='🏷 Members with no roles',
            description='\n'.join([f'{member.mention} ({member.name}#{member.discriminator})'
                                   for member in no_roles]),
            footer=f'{len(no_roles)} in total',
            colour=utils.Colours.info
        )
        await message.channel.send(embed=response)
Exemplo n.º 13
0
    async def removedataset(self, ctx, name:str):
        """Removes a user's dataset from the database (if they have one with the given name)

        Args:
            name (str): name of the dataset to remove
        """
        author = ctx.author
        num_removed = dbfunc.remove_dataset(author.id, name)
        if num_removed == 0:
            description="There is no dataset with this name to remove!"
            await ctx.send(embed=utils.error_embed(description))
        else:
            title=f"Dataset `{name}` successfully removed!"
            description=""
            color=discord.Color.green()
            await ctx.send(embed=utils.create_embed(title, description, color))
Exemplo n.º 14
0
    async def addrandomnumberrow(self, ctx, dataset_name:str, row_name:str, amount_of_random_numbers:int, minimum_number:float, maximum_number:float):
        """Adds a random row of numbers to a user's dataset, with them choosing the bounds between the numbers and
        amount of numbers.

        If the name of the row already exists, the numbers will be added to the end of that row.

        Args:
            dataset_name (str): Name of the dataset
            row_name (str): Name of the row
            amount_of_random_numbers (int): Amount of random numbers to be generated
            minimum_number (float): Minimum possible number of the random numbers
            maximum_number (float): Maximum possible number of the random numbers
        """
        #Get the data
        datadict = await asyncutils.get_data_dictionary(ctx, dataset_name)
        if datadict is None:
            return

        #Get the random list of numbers
        numlist = None
        try:
            numlist=utils.random_num_list(amount_of_random_numbers, minimum_number, maximum_number)
        except:
            description=f"An error occured while generating the random numbers. Make sure that your minimum and maximum values were entered as numbers and try again."
            await ctx.send(embed=utils.error_embed(description))
            return


        #Add the values to the end of a pre-existing list or just use the values
        previous_row_values = datadict.get(row_name, None)
        if previous_row_values is None:
            datadict[row_name] = numlist
        else:
            new_row_values = previous_row_values.copy()
            for num in numlist:
                new_row_values.append(num)
            datadict[row_name] = new_row_values

        #Write the data to the database
        data_written = await asyncutils.log_data_to_database(ctx, dataset_name, datadict)
        if data_written == False:
            return
        
        title=f"`{amount_of_random_numbers}` random number values of range `{minimum_number}` to `{maximum_number}` have been added to the `{row_name}` row! To view the values use `/viewdata {dataset_name}`"
        description=""
        color=discord.Color.green()
        await ctx.send(embed=utils.create_embed(title, description, color))
Exemplo n.º 15
0
    async def addnumberrow(self, ctx, dataset_name:str, row_name:str, numbers:str, separator:str=" "):
        """Adds a row of numbers to the data in a user's dataset. The user enters a list of numbers using a
        separator of their choice (default is " "). 

        If the name of the row already exists, the numbers will be added to the end of that row.

        Args:
            dataset_name (str): Name of the dataset to add the data to
            row_name (str): Name of the row
            numbers (str): Numbers, listed out with the separator of their choice
            separator (str, optional): The separator for the user's list of numbers.  Defaults to " ".
        """

        #Get the data
        datadict = await asyncutils.get_data_dictionary(ctx, dataset_name)
        if datadict is None:
            return

        #turn numbers string into list of numbers
        numlist = None
        try:
            numlist = utils.str2numlist(numbers, separator)
        except Exception as e:
            description="Either one of your values is not a number, or your list is not properly formatted. Please try again, or use `/help addnumberrow` for assistance."
            await ctx.send(embed=utils.error_embed(description))
            return

        #Add the numbers to the end of a pre-existing list or just use the values
        previous_row_values = datadict.get(row_name, None)
        if previous_row_values is None:
            datadict[row_name] = numlist
        else:
            new_row_values = previous_row_values.copy()
            for num in numlist:
                new_row_values.append(num)
            datadict[row_name] = new_row_values
        
        #Write the data to the database
        data_written = await asyncutils.log_data_to_database(ctx, dataset_name, datadict)
        if data_written == False:
            return
        
        title=f"Number values have been added to the `{row_name}` row!"
        description=""
        color=discord.Color.green()
        await ctx.send(embed=utils.create_embed(title, description, color))
Exemplo n.º 16
0
    async def addrandomcolorrow(self, ctx, dataset_name:str, row_name:str, amount_of_random_colors:int):
        """Adds a random row of hex color strings to a user's dataset,
         with them choosing the amount of colors.

        If the name of the row already exists, the numbers will be added to the end of that row.

        Args:
            dataset_name (str): Name of the dataset
            row_name (str): Name of the row
            amount_of_random_colors (int): Amount of random colors to be generated
        """
        #Get the data
        datadict = await asyncutils.get_data_dictionary(ctx, dataset_name)
        if datadict is None:
            return
    
        #Create random list of colors
        colorlist=[]
        try:
            for _ in range(amount_of_random_colors):
                colorlist.append(utils.generate_random_color())
        except:
            description=f"An error with color generation occurred on our end. Please use `/report` to report the issue or get help in our support server: {plotvars.support_discord_link}"
            await ctx.send(embed=utils.error_embed(description))
            return
        
        #Add the colors to the end of a pre-existing list or just use the values
        previous_row_values = datadict.get(row_name, None)
        if previous_row_values is None:
            datadict[row_name] = colorlist
        else:
            new_row_values = previous_row_values.copy()
            for color in colorlist:
                new_row_values.append(color)
            datadict[row_name] = new_row_values

        #Write the data to the database
        data_written = await asyncutils.log_data_to_database(ctx, dataset_name, datadict)
        if data_written == False:
            return


        title=f"`{amount_of_random_colors}` color values have been added to the `{row_name}` row!"
        description=""
        color=discord.Color.green()
        await ctx.send(embed=utils.create_embed(title, description, color))
Exemplo n.º 17
0
    async def setaxisoption(self, ctx, dataset_name: str, axis_option: str):
        """Sets a specific axis option for a dataset.

        Options are based on the axis options that matplotlib has.

        Args:
            dataset_name (str): Name of the dataset
            axis_option (str): Axis option
        """
        author = ctx.author
        correct_option = False
        if axis_option == "on":
            dbfunc.set_axis_info(author.id, dataset_name, axis_option)
            correct_option = True
        elif axis_option == "off":
            dbfunc.set_axis_info(author.id, dataset_name, axis_option)
            correct_option = True
        elif axis_option == "equal":
            dbfunc.set_axis_info(author.id, dataset_name, axis_option)
            correct_option = True
        elif axis_option == "scaled":
            dbfunc.set_axis_info(author.id, dataset_name, axis_option)
            correct_option = True
        elif axis_option == "tight":
            dbfunc.set_axis_info(author.id, dataset_name, axis_option)
            correct_option = True
        elif axis_option == "auto":
            dbfunc.set_axis_info(author.id, dataset_name, axis_option)
            correct_option = True
        elif axis_option == "image":
            dbfunc.set_axis_info(author.id, dataset_name, axis_option)
            correct_option = True
        elif axis_option == "square":
            dbfunc.set_axis_info(author.id, dataset_name, axis_option)
            correct_option = True

        if correct_option:
            title = f"Axis option {axis_option} has been set for dataset {dataset_name}!"
            description = ""
            colour = discord.Color.green()
            await ctx.send(embed=utils.create_embed(title, description, colour)
                           )
        else:
            description = f"Your option was not one of the valid options (either on, off, equal, scaled, tight, auto, image, or square). Please try again or reference `/help setaxisoption` for more information."
            await ctx.send(embed=utils.error_embed(description))
Exemplo n.º 18
0
    async def on_message(self, message: discord.Message, trigger: str,
                         args: list):
        role = utils.find(lambda r: r.id == 398288266677321728,
                          message.author.guild.roles)

        if role not in message.author.roles:
            action = ('added', 'to')
            await message.author.add_roles(role)
        else:
            action = ('removed', 'from')
            await message.author.remove_roles(role)

        response = utils.create_embed(
            title=message.author.display_name,
            description='{} has been {} {} you.'.format(role.name, *action),
            icon=message.author.avatar_url,
            colour=role.colour)
        await message.channel.send(embed=response)
Exemplo n.º 19
0
    async def createdataset(self, ctx, name:str):
        """Creates a dataset for the user and adds it to the database.

        Args:
            name (str): Name of the dataset
        """
        author = ctx.author
        try:
            dbfunc.set_dataset(author.id, name)

            title=f"Dataset `{name}` has been created!"
            description=""
            color=discord.Color.green()
            await ctx.send(embed=utils.create_embed(title, description, color))
        except:
            description="You already have a dataset with the same name!"
            await ctx.send(embed=utils.error_embed(description))
            return
Exemplo n.º 20
0
def rnn():
    _ = utils.create_embed()
    vocab_size = joblib.load(f'{config.MODEL_PATH}vocab_size.pkl')
    embeddings_matrix = joblib.load(f'{config.MODEL_PATH}embed_matrix.pkl')

    model = tf.keras.Sequential([
        tf.keras.layers.Embedding(vocab_size + 1,
                                  config.EMBEDDING_DIM,
                                  input_length=config.MAX_LENGTH,
                                  weights=[embeddings_matrix],
                                  trainable=False),
        tf.keras.layers.Dropout(0.4),
        tf.keras.layers.Conv1D(64, 5, activation='relu'),
        tf.keras.layers.MaxPooling1D(pool_size=4),
        tf.keras.layers.LSTM(64),
        tf.keras.layers.Dropout(0.2),
        tf.keras.layers.Dense(1, activation='sigmoid')
    ])

    return model
Exemplo n.º 21
0
    async def on_message(self, message: discord.Message, trigger: str,
                         args: list):
        if message.mentions:
            user = message.mentions[0]
        else:
            user = message.author

        fields = ((
            'Joined Discord',
            f"{arrow.get(user.created_at).format('Do MMMM YYYY')} ({arrow.get(user.created_at).humanize()})",
            False
        ), ('Joined the server',
            f"{arrow.get(user.joined_at).format('Do MMMM YYYY')} ({arrow.get(user.joined_at).humanize()})",
            False))
        response = create_embed(icon=user.avatar_url,
                                title=user.display_name,
                                colour=user.colour,
                                fields=fields)

        await message.channel.send(embed=response)
Exemplo n.º 22
0
 async def consent(self,
                   message: discord.Message,
                   accept_keyword: str = 'yes',
                   decline_keyword: str = 'no',
                   **kwargs) -> bool:
     consent_text = utils.create_embed(**kwargs)
     consent_msg = await message.channel.send(embed=consent_text)
     try:
         consent_response = await self.bot.wait_for(
             event='message',
             check=lambda m: m.content.strip().lower() in
             (accept_keyword, decline_keyword) and m.channel == message.
             channel and m.author == message.author,
             timeout=300)
         consented = True if consent_response.content.strip().lower(
         ) == accept_keyword else False
         # await consent_response.delete()
     except FutureTimeoutError:
         consented = False
     # await consent_msg.delete()
     yield consented
Exemplo n.º 23
0
    async def viewgraphdata(self, ctx, dataset_name:str):
        """Gives the user a list of their saved graphs in a certain dataset.

        Args:
            dataset_name (str): Name of the dataset
        """
        #Get the graph data
        graph_data_dict = await asyncutils.get_graph_data_dictionary(ctx, dataset_name)
        if graph_data_dict is None:
            return
        
        title=f"Saved graph data in the dataset `{dataset_name}`:"
        description = ""
        color=discord.Color.orange()
        for key, value in graph_data_dict.items():
            description+=f"{key}: {value} \n"
        
        try:   
            await ctx.send(embed=utils.create_embed(title=title, description=description, color=color))
        except:
            msg = f"Your data was unable to be sent, most likely due to discord's message character limit. Use `/viewdataintxt` to get the data with no character limit."
            await ctx.send(embed=utils.error_embed(msg))
Exemplo n.º 24
0
    async def viewdata(self, ctx, dataset_name:str):
        """Gives the user a list of their rows of data in a certain dataset,
         along with their constant graph properties.

        Args:
            dataset_name (str): Name of the dataset
        """
        author = ctx.author
        #Get the data
        datadict = await asyncutils.get_data_dictionary(ctx, dataset_name)
        if datadict is None:
            return

        title=f"Data in the dataset `{dataset_name}`:"
        description = ""
        color=discord.Color.orange()
        for key, value in datadict.items():
            description+=f"{key}: {value} \n"
        description+=f"Plot Title: {dbfunc.get_plot_title(author.id, dataset_name)}\n"
        description+=f"Axis info: {dbfunc.get_axis_info(author.id,dataset_name)}\n"

        #Get the x ticks data
        xticksdict = await asyncutils.get_xticks_dictionary(ctx, dataset_name)
        description+= f"X Ticks Dictionary: {str(xticksdict)}\n"

        #Get the y ticks data
        yticksdict = await asyncutils.get_yticks_dictionary(ctx, dataset_name)
        description+= f"Y Ticks Dictionary: {str(yticksdict)}\n"

        #Gets the legend data
        legend = dbfunc.get_legend(author.id, dataset_name)
        description+= f"Legend: {str(legend)}\n"

        try:   
            await ctx.send(embed=utils.create_embed(title=title, description=description, color=color))
        except:
            msg = f"Your data was unable to be sent, most likely due to discord's message character limit. Use `/viewdataintxt` to get the data with no character limit."
            await ctx.send(embed=utils.error_embed(msg))
Exemplo n.º 25
0
 async def on_message(self, message: discord.Message, trigger: str, args: list):
     cpu_freq = psutil.cpu_freq()
     cpu_load = psutil.cpu_percent(interval=0.25)
     memory = psutil.virtual_memory()
     memory = (humanfriendly.format_size(memory.used, binary=True).split()[0],
               humanfriendly.format_size(memory.total, binary=True))
     bot = (
         'Bot',
         f'Shards: **{self.bot.shard_count if self.bot.shard_count else "Not sharded"}**\n'
         f'Latency: **{self.bot.latency * 1000:.2f} ms**'
     )
     host = (
         'Host',
         f'CPU: **{cpu_load:.2f}%** {" at **{:.2f} Mhz**".format(cpu_freq.current) if cpu_freq else ""}\n'
         f'Memory: **{memory[0]}**/**{memory[1]}**'
     )
     response = utils.create_embed(
         title=self.bot.user.name,
         icon=self.bot.user.avatar_url,
         fields=(bot, host),
         colour=message.guild.me.top_role.colour
     )
     await message.channel.send(embed=response)
Exemplo n.º 26
0
    async def on_message(self, message: discord.Message, trigger: str,
                         args: list):
        title = 'Permissions'
        if message.channel_mentions:
            ch = message.channel_mentions[0]
            perms = ch.permissions_for(message.guild.me)
            title += f' in #{ch.name}'
        else:
            perms = message.guild.me.guild_permissions

        sets = (('General',
                 ('administrator', 'view_audit_log', 'manage_guild',
                  'manage_roles', 'manage_channels', 'kick_members',
                  'ban_members', 'create_instant_invite', 'change_nickname',
                  'manage_nicknames', 'manage_webhooks')),
                ('Text',
                 ('send_messages', 'send_tts_messages', 'manage_messages',
                  'embed_links', 'attach_files', 'read_message_history',
                  'mention_everyone', 'external_emojis', 'add_reactions')),
                ('Voice',
                 ('connect', 'speak', 'mute_members', 'deafen_members',
                  'move_members', 'use_voice_activation')))
        fields = list(
            map(
                lambda prop_set: (prop_set[0], '\n'.join([
                    f"{prop.replace('_', ' ').replace('tts', 'TTS').capitalize()}: "
                    f"**{'Y' if getattr(perms, prop) else 'N'}**"
                    for prop in prop_set[1]
                ])), sets))

        response = utils.create_embed(
            title=title,
            icon=message.author.guild.me.avatar_url,
            fields=fields,
            colour=message.author.guild.me.top_role.colour)
        await message.channel.send(embed=response)
Exemplo n.º 27
0
async def leu(ctx):
    embed = create_embed(
        'https://upload.wikimedia.org/wikipedia/commons/b/b4/1_leu._Romania%2C_2005_a.jpg'
    )
    await ctx.channel.send(f'{ctx.author.name}, ai un leu?', embed=embed)
Exemplo n.º 28
0
async def supremus(ctx):
    embed = create_embed(
        'https://media.sketchfab.com/models/263640bbe33e46febaf00d80ed3438ec/thumbnails/6fad7468a2cf449fae7003c658829788/d3d84fa90ac04e248b0dbd3ff12df660.jpeg'
    )
    await ctx.channel.send('Am găsit-o pe prietena lui Supremus... 💘',
                           embed=embed)
Exemplo n.º 29
0
 async def log_in_channel(log_channel, **kwargs):
     log_msg = utils.create_embed(**kwargs)
     await log_channel.send(embed=log_msg)
Exemplo n.º 30
0
    async def on_message(self, message: discord.Message, trigger: str,
                         args: list):
        nsfw_role = utils.find(lambda r: r.id == 398288236817940480,
                               message.author.guild.roles)
        log_channel = utils.find(lambda ch: ch.id == 422762236189081600,
                                 message.author.guild.channels)

        # Check if user is in a list of known underage
        underage = await self.bot.db.get_guild_setting(message.author.guild.id,
                                                       'underage')
        if message.author.id in underage:
            await self.log_in_channel(
                log_channel,
                title='🙅 Role denied',
                description=f"User {message.author.mention} "
                f"({message.author.name}#{message.author.discriminator}|{message.author.id}) "
                f"have tried assigning {nsfw_role.name} "
                f"at {arrow.utcnow().format('YYYY-MM-DD HH:mm:ss ZZ')}",
                timestamp=arrow.utcnow().datetime,
                colour=utils.Colours.info)
            response = utils.create_embed(
                title=message.author.display_name,
                icon=message.author.avatar_url,
                description="It seems you've been marked as an underage.\n"
                "If you would like to dispute this, contact a mod and be prepared to prove it.",
                colour=utils.Colours.warning)
            await message.channel.send(embed=response)
            return

        # Elder floofs don't need the role as they already have access
        elder_floof = utils.find(lambda r: r.id == 398292277736243200,
                                 message.author.guild.roles)
        if elder_floof in message.author.roles:
            return

        # Assign the role if user doesn't have it
        if nsfw_role not in message.author.roles:
            nsfw_category = utils.find(
                lambda cat: cat.id == 422554067706052618,
                message.guild.categories)
            nsfw_channels = ', '.join(
                [f'#{ch.name}' for ch in nsfw_category.channels])
            yes = 'yes'
            no = 'no'
            consent = f'{nsfw_role.name} role gives you access to {nsfw_channels}.\n' \
                       '**You must be 18 years or older to apply for this role.**\n' \
                       'Your local laws about pornography or consent does not mean jack shit in this server.\n' \
                       '**If you are underage and have this role you will be permabanned from this server, no exceptions.**\n\n' \
                      f'Respond with `{yes}` to proceed, `{no}` to cancel.'
            async with self.consent(message,
                                    accept_keyword=yes,
                                    decline_keyword=no,
                                    description=consent,
                                    colour=utils.Colours.danger) as consented:
                if not consented:
                    return
                await message.author.add_roles(nsfw_role)
                await self.log_in_channel(
                    log_channel,
                    title='🍆 Role update',
                    description=f"User {message.author.mention} "
                    f"({message.author.name}#{message.author.discriminator}|{message.author.id}) "
                    f"has been granted {nsfw_role.name} role at {arrow.utcnow().format('YYYY-MM-DD HH:mm:ss ZZ')}",
                    colour=utils.Colours.info,
                    timestamp=arrow.utcnow().datetime)
                response = utils.create_embed(
                    title=message.author.display_name,
                    description=f'{nsfw_role.name} has been added to you.',
                    icon=message.author.avatar_url,
                    colour=nsfw_role.colour)
                await message.channel.send(embed=response)