Beispiel #1
0
    def __init__(self, e):
        @e.slash.slash(
            name="remover_jogo",
            description="Lista de Jogos - Remova um jogo à lista",
            options=[
                create_option(
                    name="nome_do_jogo",
                    description="O nome do jogo que você deseja remover",
                    option_type=SlashCommandOptionType.STRING,
                    required=True)
            ],
            guild_ids=e.allowed_guilds["gamelist"])
        async def remover_jogo(ctx, nome_do_jogo):
            game_index = e.gamelist.index_of_closest(nome_do_jogo)
            if game_index == None:
                await ctx.send(
                    f"Não foi possível encontrar um jogo com o nome **{nome_do_jogo}**"
                )
                return

            name = e.gamelist.get_name(game_index)
            e.gamelist.remove_game(game_index)
            e.gamelist.save_to_mongo()

            await ctx.send(f":white_check_mark: | **{name}** removido!")
Beispiel #2
0
class Stan(commands.Cog):
    def __init__(self, bot: TeinfBot):
        self.bot: TeinfBot = bot

    @cog_ext.cog_slash(name="stan",
                       guild_ids=guild_ids,
                       description="Wyświetla stan konta",
                       options=[
                           manage_commands.create_option(
                               name="user",
                               description="Użtykownik",
                               option_type=SlashCommandOptionType.USER,
                               required=False)
                       ])
    async def __stan(self, ctx: SlashContext, user: discord.Member = None):
        if user is None:
            user = ctx.author

        teinf_member: TeinfMember = db_session.query(TeinfMember).filter_by(
            discordId=user.id).first()

        embd = discord.Embed(
            title="💵  TEINF BANK  💵",
            description=
            f"Stan konta {user.mention}:\n`- {teinf_member.money} chillcoinów`",
            color=discord.Color.green())

        await ctx.send(embed=embd)
Beispiel #3
0
async def register_my_tickets_command(bot, cmd) -> None:
    """Dirty hack to register options on fly for my_tickets command"""
    lotteries = await Lottery.all().order_by("-created_at").limit(10)
    try:
        # force sync_commands to detect new changes and sync slash commands with Discord
        del bot.slash.subcommands["sweepstake"]["tickets"]
    except KeyError:
        pass
    bot.slash.add_subcommand(
        cmd=cmd,
        base="sweepstake",
        name="tickets",
        description="My tickets",
        guild_ids=config.GUILD_IDS,
        options=[
            create_option(
                name="name",
                description="choose sweepstake",
                option_type=3,
                required=True,
                choices=[create_choice(name=_.name, value=_.name) for _ in lotteries],
            )
        ],
    )
    return None
Beispiel #4
0
class Tags(commands.Cog):
    def __init__(self, bot, firebase_ref):
        self.bot = bot
        self.firebase_ref = firebase_ref

    @cog_ext.cog_subcommand(
        base="tag",
        description="Create a tag.",
        guild_ids=hkd.get_all_guild_ids(),
        options=[
            create_option(
                name="name",
                description="Name of the tag, followed by the content of the tag.",
                option_type=3,
                required=True
            )
        ]
    )
    @commands.guild_only()
    async def create(self, ctx: SlashContext, name: str):
        await ctx.defer()
        if len(split_request := name.split()) > 1:
            tag_name = split_request[0]
            tag_content = name[len(tag_name) + 1:]
            if tag_name not in self.firebase_ref.child('tags').get():
                self.firebase_ref.child('tags/{0}'.format(tag_name)).set(tag_content)
                await ctx.send(embed=hkd.create_embed(title='Successfully created tag - {0}'.format(tag_name)))
            else:
                await ctx.send(embed=hkd.create_embed(title='That tag already exists. Please choose a different tag name.', colour=Colour.red()))
            return
        await ctx.send(embed=hkd.create_embed(description="Couldn't create tag.", colour=Colour.red()))
Beispiel #5
0
class Slash(commands.Cog):
    '''
    Slash commands for Discord
    '''
    def __init__(self, bot):
        self.bot = bot

    @cog_ext.cog_slash(name="hi",
                        description="just says hello",
                        guild_ids=guild_ids)
    async def hi(self, ctx: SlashContext):
        await ctx.send(content="hello", hidden=True)

    @cog_ext.cog_slash(name="invoke", options=[manage_commands.create_option(
                        name = "command",
                        description = "command to invoke",
                        option_type = 3,
                        required = True
                    )], description="Invoke a command like usual, but now with a slash!",guild_ids=guild_ids)
    async def invoke(self, ctx: SlashContext, command):
        view = StringView(command)
        m = await ctx.send(f"Invoking command `{command}`...")
        ctx = commands.Context(
            prefix=bot_prefix, view=view, bot=self.bot, message=m)
        invoker = view.get_word()
        ctx.invoked_with = invoker

        if command := self.bot.all_commands.get(invoker):
            # invoke a command
            ctx.command = command
            await self.bot.invoke(ctx)
Beispiel #6
0
def download():
    ydl_opts = {
        'format':
        'bestaudio/best',
        'postprocessors': [{
            'key': 'FFmpegExtractAudio',
            'preferredcodec': 'mp3',
            'preferredquality': '192',
        }],
        'progress_hooks': []
    }

    description = "Find an audio file, given a link. Use this if you want to quickly download something."
    options = [
        create_option(name="source",
                      description="Link to the media you want to find.",
                      option_type=SlashCommandOptionType.STRING,
                      required=True)
    ]

    @slash.slash(name="download", description=description, options=options)
    async def download(ctx, source):
        with youtube_dl.YoutubeDL(ydl_opts) as ydl:
            try:
                r = ydl.extract_info(source, download=False)
                await ctx.send(r['url'])
            except Exception as exception:
                length = 19 + len(source) + 21
                await ctx.send(
                    f"**{type(exception).__name__}**: `{str(exception)[18:length]}`"
                )
Beispiel #7
0
class Mem(commands.Cog):
    def __init__(self, bot: TeinfBot):
        self.bot: TeinfBot = bot

    @cog_ext.cog_slash(
        name="mem",
        description="Wysyła losowego mema!",
        guild_ids=guild_ids,
        options=[
            manage_commands.create_option(
                name="strona",
                description="Strona z której mają zostać wybrane memy",
                option_type=SlashCommandOptionType.STRING,
                required=False,
                choices=['jbzd.pl', 'kwejk.pl']),
        ])
    async def __mem(self, ctx: SlashContext, strona: str = None):

        strona = strona or random.choice(['jbzd.pl', 'kwejk.pl'])
        if strona == 'jbzd.pl':
            random_meme = await JbzdMeme.random_meme_async()
            await ctx.send(embed=random_meme.embed)
        elif strona == 'kwejk.pl':
            random_meme = await KwejkMeme.random_meme_async()
            await ctx.send(embed=random_meme.embed)
Beispiel #8
0
class Fun(commands.Cog):
    def __init__(self, client):
        self.client = client

    # Say
    @commands.command()
    async def say(self, ctx, *, message):
        await ctx.send(message)

    # Say
    @commands.command()
    async def test(self, ctx):
        await ctx.send(file='output/output.gif')

    # Slash Versions
    @cog_ext.cog_slash(
        name="say",
        description="WolfBot will literally just repeat your message",
        options=[
            manage_commands.create_option(name="message",
                                          description="yes",
                                          option_type=3,
                                          required=True)
        ])
    async def _say(self, ctx, message: str):
        await ctx.send(message)
Beispiel #9
0
    async def add_commands(self, slash: SlashCommand):
        base_command = self.configuration.get("command_prefix",
                                              "") + "randovania-faq"

        for game in enum_lib.iterate_enum(RandovaniaGame):
            faq_entries = list(game.data.faq)
            if not faq_entries:
                continue

            def _shorten(n: str) -> str:
                if len(n) > 100:
                    return n[:97] + "..."
                return n

            slash.add_subcommand(
                functools.partial(self.faq_game_command, game=game),
                base_command,
                name=game.value,
                description=f"Prints the answer to a FAQ for {game.long_name}.",
                options=[
                    manage_commands.create_option(
                        "question",
                        "Which question to answer?",
                        option_type=SlashCommandOptionType.STRING,
                        required=True,
                        choices=[
                            manage_commands.create_choice(
                                f"question_{question_id}", _shorten(question))
                            for question_id, (question,
                                              answer) in enumerate(faq_entries)
                        ])
                ],
            )
Beispiel #10
0
class Czas(commands.Cog):
    def __init__(self, bot: TeinfBot):
        self.bot: TeinfBot = bot

    @cog_ext.cog_slash(name="czas",  description="Wyświetla czas spędzony na serwerze",guild_ids=guild_ids, options=[
        manage_commands.create_option(
            name="user",
            description="Użytkownik",
            option_type=SlashCommandOptionType.USER,
            required=False
        )
    ])
    async def __czas(self, ctx: SlashContext, user: discord.Member = None):
        

        user = user or ctx.author

        teinfMember: TeinfMember = db_session.query(TeinfMember).filter_by(discordId=user.id).first()

        em = discord.Embed(
            title="Czas spędzony na serwerze",
            description=f"{user.display_name} spędził {TimeUtils.getTimeDescFromMinutes(teinfMember.timespent)} na serwerze",
            color=discord.Colour.green()
        )
        await ctx.send(embed=em)
Beispiel #11
0
class Info(commands.Cog):
    def __init__(self, bot: TeinfBot):
        self.bot: TeinfBot = bot

    @cog_ext.cog_slash(name="info",
                       description="Wyświetla informacje o użytkowniku",
                       guild_ids=guild_ids,
                       options=[
                           manage_commands.create_option(
                               name="user",
                               description="Użytkownik",
                               option_type=SlashCommandOptionType.USER,
                               required=False)
                       ])
    async def __info(self, ctx: SlashContext, user: discord.Member = None):

        user = user or ctx.author
        informacje = {
            "Nick": user.name,
            "ID": user.id,
            "Status": user.status,
            "Najwyższa rola": user.top_role,
            "Dołączył/a": user.joined_at,
            "#": user.discriminator,
            "Avatar": user.avatar_url,
            "Server": user.guild
        }
        wiadomosc = ""
        for key, value in informacje.items():
            wiadomosc += key + " : " + str(value) + "\n"
        em = discord.Embed(title=f"Informacje o {informacje['Nick']}",
                           description=wiadomosc,
                           colour=discord.Colour.green())
        await ctx.send(embed=em)
class MoveSlashCommands(MyCog):
    def __init__(self, bot):
        super().__init__(bot)

    @cog_ext.cog_slash(
        name="move",
        description="Request the conversation moves to another text channel",
        options=[
            manage_commands.create_option(
                name="destination",
                description="Where to move the conversation to",
                option_type=SlashCommandOptionType.CHANNEL,
                required=True,
            ),
        ])
    # ],
    # guild_ids=[514223116893945856])
    async def move_slash(self, ctx: SlashContext, destination: GuildChannel):
        try:
            _, destination = move_check(ctx, destination)
        except CommandUseFailure as error:
            await ctx.send(content=error.message, hidden=True)
            return
        origin_text, dest_text = get_pre_move_text()
        origin = await ctx.send(content=origin_text)
        dest = await destination.send(dest_text)
        origin_embed, dest_embed = get_move_text(origin, dest, ctx.author)
        await origin.edit(content="", embed=origin_embed)
        await dest.edit(content=None, embed=dest_embed)
Beispiel #13
0
def add_faq_slashcommands(slash: SlashCommand, faqs: List[FAQ]) -> None:
    """
    Register /faq subcommands for each FAQ.

    This is pretty ugly - it'd be nicer if we could do this with a Cog or something,
    but Discord's commands are still in beta, so nothing is really ready yet.
    """

    if len(faqs) <= 10:
        # Slash commands don't accept more than 10 options, so we only can
        # register it then. Yes, that is incredibly stupid.
        for faq in faqs:
            _add_slash(slash, faq)
    else:

        @slash.slash(
            name="faq",
            description="Retrieves FAQs related to given keyword(s).",
            options=[
                manage_commands.create_option(
                    name="search",
                    description="The FAQ to find.",
                    option_type=3,
                    required=True,
                ),
            ],
            guild_ids=guild_ids(),
        )
        async def _run(ctx: SlashContext, search: str) -> None:
            await _search(ctx, faqs, search)
Beispiel #14
0
class Rank(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    def cog_unload(self):
        self.bot.slash.remove_cog_commands(self)

    @cog_ext.cog_slash(
        name='rank',
        description='Sees your, or another user\'s rank',
        guild_ids=[740531414008856596],
        options=[
            manage_commands.create_option(
                name="user",
                description="the user you want to see the rank of",
                option_type=6,
                required=False)
        ])
    async def rank(self,
                   ctx,
                   user: typing.Union[discord.Member, discord.User] = None):
        await ctx.respond()
        user = user or ctx.author
        xp = await db.get(user, 'xp')
        level = await db.get(user, 'level')
        embed = discord.Embed(title=f'{user}\'s rank',
                              description=f'__XP:__ {xp}\n__Level:__ {level}')
        await ctx.send(embed=embed)
 def __init__(self,
              name,
              description,
              type_,
              required,
              choices=[],
              usage=None):
     self.option = manage_commands.create_option(name, description, type_,
                                                 required, choices)
     self.name = name
     self.description = description
     self.type = self.option["type"]
     self.required = required
     self.choices = self.option["choices"]
     if usage:
         self.usage = usage
     else:
         usage = self.name
         if self.choices:
             usage = "|".join(choice["name"] for choice in self.choices)
         # TODO: Handle subcommands and groups
         if self.required:
             self.usage = "<" + usage + ">"
         else:
             self.usage = "[" + usage + "]"
Beispiel #16
0
class Slash(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @cog_ext.cog_slash(name="neko", description="にゃーんと鳴くやつ")
    async def neko(self, ctx: SlashContext):
        "にゃーんと鳴くやつ"
        # embed = discord.Embed(title="鳴き声")
        await ctx.send(content=f"{ctx.author.mention} にゃーん")

    @cog_ext.cog_slash(name="echo",
                       description="引数を1つ受け取り、そのまま返す",
                       options=[
                           create_option(name="arg",
                                         description="引数",
                                         option_type=3,
                                         required=True)
                       ])
    async def echo(self, ctx: SlashContext, arg: str):
        "引数を1つ受け取り、そのまま返す"
        await ctx.send(content=arg)

    @commands.command()
    async def ping(self, ctx: commands.Context):
        await ctx.send("pong")
Beispiel #17
0
class Dua(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self.url = 'https://ahadith.co.uk/hisnulmuslim-dua-{}'

    @staticmethod
    def get_dua_id(subject):
        return DUAS[subject]

    async def _dua(self, ctx, subject: str):
        subject = subject.title()
        dua_id = self.get_dua_id(subject)

        site_source = await get_site_source(self.url.format(dua_id))
        dua_text = []
        for dua in site_source.findAll("div", {"class": 'search-item'}):
            text = dua.get_text(separator=" ").strip()\
                .replace("(saw)", "ﷺ")
            text = '\n' + text
            dua_text.append(text)
        dua_text = ''.join(dua_text)
        dua_text = re.sub(r'\d+', '', dua_text)

        em = discord.Embed(title=f'Duas for {subject.title()}', colour=0x467f05, description=dua_text)
        em.set_author(name="Fortress of the Muslim", icon_url=ICON)
        await ctx.send(embed=em)

    @commands.command(name='dua')
    async def dua(self, ctx, *, subject: str):
        await self._dua(ctx, subject)

    @dua.error
    async def on_dua_error(self, ctx, error):
        if isinstance(error, MissingRequiredArgument):
            await ctx.send(f"**You need to provide a dua topic**. Type `{ctx.prefix}dualist` for a list of dua topics.")
        if isinstance(error, KeyError):
            await ctx.send(f"**Could not find dua for this topic.** Type `{ctx.prefix}dualist` for a list of dua topics.")

    @cog_ext.cog_slash(name="dua", description="Send ʾadʿiyah by topic.",
                       options=[
                           create_option(
                               name="topic",
                               description="The topic of the dua.",
                               option_type=3,
                               required=True,
                               choices=generate_choices_from_list(list(DUAS.keys())))])
    async def slash_dua(self, ctx: SlashContext, subject: str):
        await ctx.defer()
        await self._dua(ctx, subject)

    @commands.command(name='dualist')
    async def dualist(self, ctx):
        dua_list_message = ['**Type {0}dua <topic>**. Example: `{0}dua breaking fast`\n'.format(ctx.prefix)]

        for dua in DUAS:
            dua_list_message.append('\n' + dua)

        em = discord.Embed(title=f'Dua List', colour=0x467f05, description=''.join(dua_list_message))
        em.set_footer(text="Source: Fortress of the Muslim (Hisn al-Muslim)")
        await ctx.send(embed=em)
Beispiel #18
0
def add_faq_slashcommands(slash: SlashCommand, faqs: List[FAQ]) -> None:
    """
    Register /faq subcommands for each FAQ.

    This is pretty ugly - it'd be nicer if we could do this with a Cog or something,
    but Discord's commands are still in beta, so nothing is really ready yet.
    """

    if len(faqs) <= 25:
        # Slash commands don't accept more than 25 options, so we only can
        # register it then. Thankfully we shouldn't hit that limit for a while.
        for faq in faqs:
            _add_slash(slash, faq)
    else:

        @slash.slash(
            name="faq",
            description="Retrieves FAQs related to given keyword(s).",
            options=[
                manage_commands.create_option(
                    name="search",
                    description="The FAQ to find.",
                    option_type=3,
                    required=True,
                ),
            ],
            guild_ids=guild_ids(),
        )
        @with_async_timer(COMMAND_TIME.labels('faq', 'slash'))
        async def _run(ctx: SlashContext, search: str) -> None:
            await _search(ctx, faqs, search)
Beispiel #19
0
async def on_ready():
    channel = bot.get_channel(756568695320608910)  # Gets the channel with this channel id
    print(f'{bot.user.name} has connected to Discord')  # Sends an online message to the command line
    await bot.change_presence(activity=discord.Game(name="search and record"))
    # Sends an online message to the aforementioned channel
    message = await channel.send(f'{bot.user.name} has connected to discord')
    msg = 'WolframLanguageSession Initialized'
    await message.edit(content=f"{bot.user.name} has connected to discord\n{msg}")
    embed_var = discord.Embed(title='Thank you for using me!', description="Powered by:", color=0xff000b)
    embed_var.set_thumbnail(url='https://www.python.org/static/community_logos/python-logo-master-v3-TM.png')
    await message.edit(embed=embed_var)  # Send a thank you message with a powered by Python message

    backend_operations.load_data_file()
    backend_operations.data["running"] = True
    backend_operations.dump_data()

    @slash.slash(name="describe", guild_ids=guild_ids, options=[
        create_option(name="arg", description="Non-req argument", option_type=3, required=False)
    ])
    async def _describe(ctx, arg):
        description_msg = f'I am a Discord bot created by Joshua Estes and Logan Gordy in an ' \
                          f'effort to make a bot that can do an assortment of different task determine ' \
                          f'by the users. I am currently on version {version_num}. Try "Hey Google, help" to ' \
                          f'get started.'
        embed_var = discord.Embed(title='Who am I?', description=description_msg, color=0x00ff00)
        embed_var.set_thumbnail(url='https://th.bing.com/th/id/OIP.7ZvVP00p4WDHmErvpPw88gHaHa?pid=Api&rs=1')
        await ctx.channel.send(embed=embed_var)
Beispiel #20
0
class Level(commands.Cog):
    def __init__(self, bot: TeinfBot):
        self.bot: TeinfBot = bot

    @cog_ext.cog_slash(name="level",
                       description="Wyświetla poziom",
                       guild_ids=guild_ids,
                       options=[
                           manage_commands.create_option(
                               name="user",
                               description="Użytkownik",
                               option_type=SlashCommandOptionType.USER,
                               required=False)
                       ])
    async def __level(self, ctx: SlashContext, user: discord.Member = None):

        user = user or ctx.author
        teinf_user: TeinfMember = db_session.query(TeinfMember).filter_by(
            discordId=user.id).first()
        level = LevelsUtils.levelFromExp(teinf_user.exp)
        next_level_exp = LevelsUtils.expFromLevel(level + 1)
        missing_exp_to_lvlup = int(next_level_exp - teinf_user.exp)

        embed = discord.Embed(
            title="💎 LEVEL 💎",
            description=
            f"Wykres poziomu {user.mention}\n`{level}LVL - {teinf_user.exp}EXP.`\nBrakuje `{missing_exp_to_lvlup}` do kolejnego poziomu.",
            color=discord.Color.blue())

        embed.set_footer(text=str(ctx.author), icon_url=ctx.author.avatar_url)

        await ctx.send(embed=embed)
Beispiel #21
0
    def __init__(self, e):

        @e.slash.slash(
            name="adicionar_jogo",
            description="Lista de Jogos - Adicione um jogo à lista",
            options=[
                create_option(
                    name="nome_do_jogo",
                    description="O nome do jogo que você deseja adicionar",
                    option_type=SlashCommandOptionType.STRING,
                    required=True
                )
            ],
            guild_ids=e.allowed_guilds["gamelist"]
        )
        async def adicionar_jogo(ctx, nome_do_jogo):

            #msg = await ctx.send(f":hourglass_flowing_sand: | Carregando...")

            e.gamelist.create_game(
                nome_do_jogo,
                added_by=ctx.author.id
            )
            e.gamelist.sort()
            e.gamelist.save_to_mongo()

            await ctx.send(content=f":white_check_mark: | **{nome_do_jogo}** adicionado com sucesso!")
Beispiel #22
0
class SlashCourse(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @cog_ext.cog_slash(
        name="course",
        description="Displays information about a course.",
        options=[
            create_option(
                name="course",
                description="The course code.",
                option_type=3,
                required=True,
            ),
            create_option(
                name="school",
                description="The school the course is at.",
                option_type=3,
                required=False,
                choices=[
                    create_choice(name="Queens University", value="queens"),
                    create_choice(name="University of Waterloo",
                                  value="waterloo"),
                    create_choice(name="University of Toronto", value="uoft"),
                ],
            ),
        ],
    )
    async def _course(self, ctx, course, school=None):
        """/course"""
        if " " in course:
            course = course.split(" ")
            course = f"{course[0].upper()}-{course[1]}"
        else:
            final = ""
            if "-" not in course:
                dash = False
                for i in course:
                    if i.isnumeric() and not dash:
                        final += "-" + i.upper()
                        dash = True
                    else:
                        final += i.upper()

                course = final

        await call_course(ctx, self.bot, course, school)
Beispiel #23
0
class Music(commands.Cog):

    music_player: MusicPlayer = None

    def __init__(self, bot: TeinfBot):
        self.bot: TeinfBot = bot
        self.music_player = MusicPlayer(bot)

    @cog_ext.cog_slash(name="music", description="Granie muzyki", guild_ids=guild_ids)
    async def __music(self, ctx: SlashContext):
        pass

    @cog_ext.cog_subcommand(base='music', name='play', description="Włącza podaną piosenkę", guild_ids=guild_ids, options=[
        manage_commands.create_option(
            name="url",
            description="Link do muzyki",
            option_type=SlashCommandOptionType.STRING,
            required=True
        )
    ])
    async def __music_play(self, ctx: SlashContext, url: str):
        await self.music_player.play(url, ctx)

    @cog_ext.cog_subcommand(base='music', name='now', description="Pokazuje obecnie graną piosenkę", guild_ids=guild_ids)
    async def __music_now(self, ctx: SlashContext):
        music_video = self.music_player.playing_now
        em = discord.Embed(
            title="MUSIC BOT",
            description=f"Obecnie gram {music_video.title}\n{music_video.webpage}",
            color=discord.Colour.dark_green()
        )
        em.set_thumbnail(url=music_video.thumbnail)
        await ctx.send(embed=em)

    @cog_ext.cog_subcommand(base='music', name='pause', description="Pauzuje piosenkę", guild_ids=guild_ids)
    async def __music_pause(self, ctx: SlashContext):
        await self.music_player.pause()
        await ctx.send("Zapauzowano", hidden=True)

    @cog_ext.cog_subcommand(base='music', name='resume', description="Wznawia piosenkę", guild_ids=guild_ids)
    async def __music_resume(self, ctx: SlashContext):
        await self.music_player.resume()
        await ctx.send("Wznowiono", hidden=True)

    @cog_ext.cog_subcommand(base='music', name='stop', description="Wyłącza granie piosenek", guild_ids=guild_ids)
    async def __music_stop(self, ctx: SlashContext):
        await self.music_player.stop()
        await ctx.send("Zastopowano", hidden=True)

    @cog_ext.cog_subcommand(base='music', name='skip', description="Przechodzi do następnego utworu", guild_ids=guild_ids)
    async def __music_skip(self, ctx: SlashContext):
        await self.music_player.skip()
        await ctx.send("Skipnięto", hidden=True)

    @cog_ext.cog_subcommand(base='music', name='clear', description="Czyści kolejkę grania", guild_ids=guild_ids)
    async def __music_clear(self, ctx: SlashContext):
        await self.music_player.queue.clear()
        await ctx.send("Wyczyszczono playlistę", hidden=True)
Beispiel #24
0
class Help(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    # ---       SLASH COMMANDS       --- #
    @cog_ext.cog_slash(name='help',
                       description='Detailed list of bot commands!',
                       guild_ids=guild_ids,
                       options=[
                           create_option(name='module',
                                         description='Choose category!',
                                         required=True,
                                         option_type=3,
                                         choices=[
                                             create_choice(
                                                 name='Administration',
                                                 value='admin'),
                                             create_choice(name='Info',
                                                           value='info'),
                                             create_choice(name='Market',
                                                           value='market')
                                         ])
                       ])
    async def _help(self, ctx: SlashContext, module: str):
        if module == 'admin':
            embed = discord.Embed(title='Administration',
                                  description=' ',
                                  colour=discord.Colour.blurple())
            embed.set_author(name='Commands List', icon_url=BOT_AVATAR)
            embed.add_field(name=';prune __Amount__',
                            value='Removes the amount of messages specified',
                            inline=False)
            embed.add_field(name=';mute __@user / user ID__',
                            value='Mutes the specified user',
                            inline=False)
            embed.add_field(name=';unmute __@user / user ID__',
                            value='Unmutes the specified user',
                            inline=False)
            embed.set_footer(
                text='User IDs can be found by turning on "Developer Mode"')
        elif module == 'info':
            embed = discord.Embed(title='Info',
                                  description=' ',
                                  colour=discord.Colour.blurple())
            embed.set_author(name='Commands List', icon_url=BOT_AVATAR)
            embed.add_field(name=';ping', value='pong!', inline=False)
        elif module == 'market':
            embed = discord.Embed(title='Market',
                                  description=' ',
                                  colour=discord.Colour.blurple())
            embed.set_author(name='Commands List', icon_url=BOT_AVATAR)
            embed.add_field(name=';coin __1-100__ or ;coin __name__',
                            value='Displays Name / Current Price',
                            inline=False)
            embed.add_field(name=';top __1-100__',
                            value='Displays the top # coins',
                            inline=False)
        await ctx.send(embeds=[embed])
Beispiel #25
0
    def __init__(self, e):
        @e.slash.slash(
            name="ver_jogo",
            description=
            "Lista de Jogos - Veja mais detalhes sobre um jogo especifico",
            options=[
                create_option(
                    name="nome_do_jogo",
                    description="O nome do jogo para ver mais sobre ele",
                    option_type=SlashCommandOptionType.STRING,
                    required=True)
            ],
            guild_ids=e.allowed_guilds["gamelist"])
        async def ver_jogo(ctx, nome_do_jogo):
            game_index = e.gamelist.index_of_closest(nome_do_jogo)
            if game_index == None:
                await ctx.send(
                    f"Não foi possível encontrar um jogo com o nome **{nome_do_jogo}**"
                )
                return

            game_embed = Embed(title=e.gamelist.get_name(game_index),
                               color=0x00b934)

            icon_url = e.gamelist.get_icon(game_index)
            if type(icon_url) == str:
                game_embed.set_thumbnail(url=icon_url)

            source = e.gamelist.get_source(game_index)
            if type(source) == str:
                game_embed.url = source

            added_by = e.gamelist.get_added_by(game_index)
            if added_by != None:
                added_by_user = await e.bot.fetch_user(added_by)
                game_embed.set_footer(icon_url=added_by_user.avatar_url,
                                      text="Jogo adicionado por " +
                                      added_by_user.display_name)

            ratings = e.gamelist.get_ratings(game_index)
            if len(ratings) != 0:
                ratings_text = ""
                for rating in ratings:
                    rating_author = await e.bot.fetch_user(rating['author'])
                    ratings_text += f"{rating_author.mention} - `{rating['rating']}/10`"
                    if rating.get("opinion", None) != None:
                        ratings_text += f" *\"{rating['opinion']}\"*"
                    ratings_text += "\n"

                game_embed.add_field(
                    name=
                    f":star: | Avaliações ({e.gamelist.get_rating_median(game_index)}/10)",
                    value=ratings_text,
                    inline=False)

            await ctx.send(
                f":bookmark_tabs: | Aqui estão algumas informações sobre **{e.gamelist.get_name(game_index)}**",
                embed=game_embed)
Beispiel #26
0
def create_person_options(maximum: int):
    output = [
        create_option(
            "user1",
            "The first person you want to cc",
            option_type=SlashCommandOptionType.USER,
            required=True,
        )
    ]
    output.extend([
        create_option(
            f"user{x}",
            "Another person you want to cc",
            option_type=SlashCommandOptionType.USER,
            required=False,
        ) for x in range(2, maximum)
    ])
    return output
Beispiel #27
0
class ListPermissions(commands.Cog):
    """List Permissions for a specified user/role"""
    def __init__(self, bot):
        self.bot = bot

        self.emoji = bot.emoji_list

        self.paginator = pagination.LinePaginator(prefix="", suffix="")

    @cog_ext.cog_subcommand(
        base="permissions",
        name="get",
        description="Get the permissions of a role or user",
        base_default_permission=True,
        options=[
            manage_commands.create_option(
                name="scope",
                description="Do you want guild perms, or channel overrides",
                required=True,
                option_type=4,
                choices=[
                    manage_commands.create_choice(value=1, name="guild"),
                    manage_commands.create_choice(value=2, name="channel"),
                ],
            ),
            manage_commands.create_option(
                name="target",
                description="The user or role you want to get perms for",
                required=True,
                option_type=9),
        ],
    )
    async def get_permissions(self, ctx: SlashContext, **kwargs):
        mention = int(kwargs.get("target"))

        if user := ctx.guild.get_member(mention):
            if kwargs.get("scope") == 1:
                return await self.perms_guild(ctx, user)
            return await self.perms_channel(ctx, user)

        elif role := ctx.guild.get_role(mention):
            if kwargs.get("scope") == 1:
                return await self.perms_guild(ctx, role)
            return await self.perms_channel(ctx, role)
Beispiel #28
0
def stats():
    description = "Check a fighter's statistics."
    options = [
        create_option(name="fighter",
                      description="The fighter to check.",
                      option_type=SlashCommandOptionType.USER,
                      required=True)
    ]

    @slash.slash(name="stats", description=description, options=options)
    async def stats(ctx, fighter):
        fullstats = stathandler.read(fighter.id)
        if not fullstats[0]:
            embed = discord.Embed(
                title=ctx.author.name +
                " doesn't seem to have any statistics.",
                description="If you're " + fighter.name +
                " and want to change these, use /setstats to set your statistics!",
                color=0x00ff00)
            await ctx.send(embed=embed)
        else:
            fstats = fullstats[1]
            embed = discord.Embed(
                title=fighter.name + "'s Statistics",
                description="If you're " + fighter.name +
                " and want to change these, use /setstats to set your statistics!",
                colour=0x00ff00)
            embed.add_field(name="Special Attack:",
                            value=fstats[1],
                            inline=False)
            embed.add_field(name="Weapon:", value=fstats[2], inline=False)
            embed.add_field(name="Lucky Number:",
                            value=fstats[3],
                            inline=False)
            embed.add_field(name="Total Fights:",
                            value=fstats[4],
                            inline=False)
            embed.add_field(name="Wins:", value=str(fstats[5]), inline=False)
            embed.add_field(name="Losses:", value=str(fstats[6]), inline=False)
            embed.add_field(name="Draws:", value=str(fstats[7]), inline=False)
            embed.add_field(name="1s Rolled:",
                            value=str(fstats[8]),
                            inline=False)
            embed.add_field(name="20s Rolled:",
                            value=str(fstats[9]),
                            inline=False)
            embed.add_field(name="Lucky Numbers Rolled:",
                            value=str(fstats[10]),
                            inline=False)
            embed.add_field(name="Seventeens Used For Healing:",
                            value=str(fstats[11]),
                            inline=False)
            embed.add_field(name="Clashes:",
                            value=str(fstats[12]),
                            inline=False)
            await ctx.send(embed=embed)
Beispiel #29
0
 def __init__(self, e):
     @e.slash.slash(
         name="roleta",
         description="Um número aleatório!",
         options=[
             create_option(name="mínimo",
                           description="Valor mínimo para sortear",
                           option_type=SlashCommandOptionType.INTEGER,
                           required=False),
             create_option(name="máximo",
                           description="Valor máximo para sortear",
                           option_type=SlashCommandOptionType.INTEGER,
                           required=False),
         ],
         guild_ids=e.allowed_guilds["default"])
     async def roleta(ctx, mínimo=1, máximo=10):
         await ctx.send(
             f":game_die: | A roleta entre `{mínimo}` e `{máximo}` deu... **{randint(mínimo, máximo)}**!"
         )
Beispiel #30
0
    def __init__(self, e):
        @e.slash.slash(
            name="avaliar_jogo",
            description="Lista de Jogos - Dê uma nota e sua opinião sobre um jogo!",
            options=[
                create_option(
                    name="nome_do_jogo",
                    description="O nome do jogo que você deseja avaliar",
                    option_type=OptionTypes.STRING,
                    required=True
                ),
                create_option(
                    name="nota",
                    description="A Nota do jogo de `0` a `10`",
                    option_type=OptionTypes.NUMBER,
                    required=True
                ),
                create_option(
                    name="opinião",
                    description="A sua opinião sobre o jogo",
                    option_type=OptionTypes.STRING,
                    required=False
                )
            ],
            guild_ids=e.allowed_guilds["gamelist"]
        )
        async def avaliar_jogo(ctx, nome_do_jogo, nota, opinião=None):
            game_index = e.gamelist.index_of_closest(nome_do_jogo)
            if game_index == None:
                await ctx.send(f"Não foi possível encontrar um jogo com o nome **{nome_do_jogo}**")
                return
            
            try:
                nota = float(nota)
                nota = max(min(nota, 10), 0)
            except:
                await ctx.send(":warning: | Esta nota é inválida")
                return
            
            e.gamelist.rate_game(game_index, ctx.author.id, nota, opinion=opinião)
            e.gamelist.save_to_mongo()

            await ctx.send(f":star: | **{ctx.author.display_name}** avaliou o jogo **{e.gamelist.get_name(game_index)}** com `{str(nota)}/10`!")