Beispiel #1
0
    async def getproducts(self, ctx):
        dbresponse = getproducts()
        embed = Embed(
            title="Products",
            description=f"Here is all the products I was able to get for this server!",
            colour=ctx.author.colour,
            timestamp=nextcord.utils.utcnow(),
        )

        fields = []

        for product in dbresponse:
            fields.append(
                (
                    product["name"],
                    "Product Description: "
                    + str(product["description"])
                    + "\nProduct Price: "
                    + str(product["price"]),
                    False,
                )
            )

        for name, value, inline in fields:
            embed.add_field(name=name, value=value, inline=inline)

        embed.set_footer(text="Redon Tech RPH • By: parker02311")

        await ctx.send(embed=embed, reference=ctx.message)
Beispiel #2
0
    async def sendToChat(self, ctx, userOne: User, userTwo: User = None):
        length = 0
        attempts = 0
        existingDict = False
        phrase = ""
        text_channel = ctx.channel  #chat channel

        markovDict, existingDict = await Markov.load_pickle(
            os.path.join(self._chains_dir,
                         str(userOne) + MarkovCommands._CHAINSEXT))
        if existingDict:
            while ((phrase == "" or length < 5)
                   and attempts < 10):  #Generate new phrase if last one sucked
                try:
                    phrase, length = await Markov.generateChain(
                        markovDict, True)
                except (
                        KeyError
                ):  #On error just make a new phrase (I'll fix this later maybe)
                    continue

            if attempts >= 10:
                await ctx.send("Exceeded number of attempts for " +
                               str(userOne))
            else:
                embed = Embed(
                    title=':speaking_head: Markov :person_shrugging:',
                    color=0x228B22)
                embed.add_field(name=str(userOne), value=phrase.capitalize())
                await ctx.send(embed=embed)
        else:
            await ctx.send("No existing Markov dictionary for " +
                           str(userOne) + ".\nUse \"d!collect <@" +
                           str(userOne.id) + ">\"")
Beispiel #3
0
    async def profile(self, ctx, member: Optional[Member]):
        member = member or ctx.author

        userinfo = getuserfromdiscord(member.id)
        if userinfo:
            embed = Embed(
                title=member.display_name,
                description=f"Here is the info on {member.mention}",
                colour=member.colour,
                timestamp=nextcord.utils.utcnow(),
            )

            fields = [
                ("UserID", userinfo["_id"], True),
                ("Username", userinfo["username"], True),
                (
                    "Owned Products",
                    "\n".join([product for product in userinfo["purchases"]])
                    or "None",
                    True,
                ),
            ]

            for name, value, inline in fields:
                embed.add_field(name=name, value=value, inline=inline)

            await ctx.send(embed=embed, reference=ctx.message)
        else:
            await ctx.send(
                f"I was unable to find any info on {member.display_name}.",
                reference=ctx.message,
            )
Beispiel #4
0
async def sources(intr: Interaction):
    """List all the sources supported"""
    if not await assert_check(intr, is_direct_only):
        return

    await intr.response.defer()

    embed = Embed(
        title="Supported sources",
        description=
        "This embed shows the list of all the sources currently supported",
        url=
        "https://novelsave-sources.readthedocs.io/en/latest/content/support.html#supported-novel-sources",
    )

    for gateway in sorted(source_service.get_novel_sources(),
                          key=lambda g: g.base_url):
        value = f"search: {'✅' if gateway.is_search_capable else '❌'}"
        embed.add_field(name=f"<{gateway.base_url}>", value=value)

    embed.set_footer(text=f"Version {source_service.current_version}")

    request_embed = Embed(
        title="Looking for something else?",
        description=
        "You can request a new source by creating an issue at github",
        url="https://github.com/mensch272/novelsave/issues/new/choose",
    )

    await intr.send(embeds=[embed, request_embed])
 async def cmd_help(self, ctx, command):
     embed = Embed(
         title=f"Help with `{command}`",
         description=syntax(command),
         colour=ctx.author.colour,
     )
     embed.add_field(name="Command Description", value=command.brief)
     embed.set_footer(text="Pembroke Bot • By: parker02311")
     await ctx.send(embed=embed, reference=ctx.message)
Beispiel #6
0
 async def modules(self, ctx: commands.Context):
     """Syntax: !modules <>
     Part of admin cog
     :return a list of numbers"""
     if ctx.message.author.guild_permissions.administrator:
         embed = Embed(title="Gavin: Here are the modules")
         for m_name, c_object in self.bot.cogs.items():
             embed.add_field(name=f"Module: {m_name}", value=f"Reload: cogs.{m_name.lower()}cog", inline=False)
         await ctx.channel.send(embed=embed)
Beispiel #7
0
 def buildembed(json_object, ableto, type):
     embed = Embed(title='<:sipsScared:819393684549533716> Name: ' + str(json_object['name']), color=0x228B22)
     embed.add_field(name='Health', value=str(json_object['currenthealth']) + '/' + str(json_object['maxhealth']), inline=True)
     embed.add_field(name='Food', value=str(json_object['food']) + '/100', inline=True)
     embed.add_field(name='Water', value=str(json_object['water']) + '/100', inline=True)
     embed.add_field(name='Cleanliness', value=str(json_object['cleanliness']) + '/100', inline=True)
     embed.add_field(name='Happiness', value=str(json_object['happiness']) + '/100', inline=True)
     if not ableto:
         embed.set_footer(text='Unable to ' + type + ' right now.')
     return embed
Beispiel #8
0
 async def on_message_delete(self, message: Message) -> None:
     logging_channel = message.guild.get_channel(int(os.environ["LOGGING_CHANNEL"]))
     embed = Embed(
         title="Message Deleted",
         description=f"{message.author.mention}'s message in {message.channel.mention} was deleted",
         color=Color.red(),
     )
     embed.add_field(name="Message", value=message.content)
     embed.set_thumbnail(url=message.author.avatar.url)
     embed.timestamp = datetime.now()
     await logging_channel.send(embed=embed)
Beispiel #9
0
 async def on_message_edit(self, before: Message, after: Message) -> None:
     logging_channel = before.guild.get_channel(int(os.environ["LOGGING_CHANNEL"]))
     embed = Embed(
         title="Message Edited",
         description=f"{before.author.mention}'s message in {before.channel.mention} was edited",
         color=Color.red(),
     )
     embed.add_field(name="Before", value=before.content, inline=False)
     embed.add_field(name="After", value=after.content, inline=False)
     embed.set_thumbnail(url=before.author.avatar.url)
     embed.timestamp = datetime.now()
     await logging_channel.send(embed=embed)
Beispiel #10
0
 async def checktime(self, ctx):
     pet = PetHandler.getcurrentpet()
     embed = Embed(title=':motorized_wheelchair: Name: ' + str(pet['name'] + ' :motorized_wheelchair:'), color=0x228B22)
     embed.add_field(name='Last Checked', value=str(pet['lastchecked']), inline=True)
     embed.add_field(name='Last Fed', value=str(pet['lastfeed']), inline=True)
     embed.add_field(name='Last Watered', value=str(pet['lastwatered']), inline=True)
     embed.add_field(name='Last Cleaned', value=str(pet['lastcleaned']), inline=True)
     embed.add_field(name='Last Pet', value=str(pet['lastpet']), inline=True)
     await ctx.send(embed=embed)
Beispiel #11
0
    def build_rule_message_embed(self, title: str,
                                 message: str) -> nextcord.Embed:
        admin: nextcord.Member = self.server.get_member(266432511897370625)
        embed = Embed(
            title=title,
            description=message,
            timestamp=datetime.now().astimezone(pytz.timezone("US/Eastern")),
            color=BLUE,
        )
        embed.set_footer(text=admin.name, icon_url=admin.avatar.url)

        for field_title, field_content in self.message_fields.items():
            embed.add_field(name=field_title,
                            value=field_content["description"],
                            inline=False)

        return embed
    async def racerinfo(self, ctx):
        embed = Embed(color=0x228B22)
        package_dir = os.path.dirname(os.path.abspath(__file__))
        thefile = os.path.join(package_dir, 'emojiracers.txt')
        with open(thefile) as json_file:
            json_object = json.load(json_file)
            json_file.close()

        emojilist = json_object['emojilist']

        for emoji in emojilist:
            embed.add_field(
                name=emoji['emoji'],
                value='Won: ' + str(emoji['wins']) + '\nLoss: ' + str(
                    (emoji['totalraces'] - emoji['wins'])) + '\nWin%: ' +
                str(math.ceil((emoji['wins'] / emoji['totalraces']) * 100)),
                inline=True)
        await ctx.send(embed=embed)
Beispiel #13
0
    async def list_tips(self, channel, tips, label=None):
        formatted = [f"- {tip.label}" for tip in tips]
        message = "Here are all tips that are available"
        title = "Available Tips"

        if label:
            message = f"Here are the tips that are similar to *{label}*"
            title = "Possible Matches"

        if not len(formatted):
            message = "*No Tips Found*"

        embed = Embed(description=message, color=0x306998, title=title)
        while formatted:
            index = min(len(formatted), 5)
            embed.add_field(name="- - - -", value="\n".join(formatted[:index]))
            formatted = formatted[index:]

        await channel.send(embed=embed)
    async def write_page(self, menu, fields=[]):
        offset = (menu.current_page * self.per_page) + 1
        len_data = len(self.entries)

        embed = Embed(
            title="Help",
            description="Get help on all commands!",
            colour=self.ctx.author.colour,
            timestamp=nextcord.utils.utcnow(),
        )
        embed.set_footer(
            text=
            f"Redon Tech RPH • {offset:,} - {min(len_data, offset+self.per_page-1):,} of {len_data:,} commands • By: parker02311"
        )

        for name, value in fields:
            embed.add_field(name=name, value=value, inline=False)

        return embed
Beispiel #15
0
 async def disabled(self, ctx):
     """Display Disabled Commands"""
     results = tool.returnDisabled(ctx.message.guild.id, self.c)
     modules = {}
     for m_name, c_object in self.bot.cogs.items():
         modules[f"cogs.{m_name.lower()}cog"] = {}
     for collection in results:
         module = collection[0]
         command = collection[1]
         channelID = "<#" + str(collection[2]) + ">"
         try:
             modules[module][channelID] = command
         except KeyError as e:
             self.logger.error(f"Error: {e}")
     embeds = []
     embedsTitle = []
     for i, collection in enumerate(results):
         moduleName = collection[0]
         title = f"Disabled for: {moduleName}"
         if i == 0:
             embed = Embed(title=title)
             embedsTitle.append(title)
             embeds.append(embed)
             if modules[moduleName]:
                 for key, value in modules[moduleName].items():
                     embed.add_field(name=f"Command: {str(value)}", value=f"Channel: !{str(key)}")
         else:
             if title in embedsTitle:
                 e = embedsTitle.index(title)
                 c_embed = embeds[e]
                 if modules[moduleName]:
                     for key, value in modules[moduleName].items():
                         c_embed.add_field(name=f"Command: {str(value)}", value=f"Channel: !{str(key)}")
             else:
                 embed = Embed(title=title)
                 embedsTitle.append(title)
                 embeds.append(embed)
                 if modules[moduleName]:
                     for key, value in modules[moduleName].items():
                         embed.add_field(name=f"Command: {str(value)}", value=f"Channel: !{str(key)}")
     for embed in embeds:
         await ctx.send(embed=embed)
Beispiel #16
0
    async def _embed_substatus(self,
                               ctx,
                               title='Batsu Games',
                               status_report=None,
                               link=None):
        if status_report is None:
            status_report = []

        embed = Embed(title=title,
                      color=0xFF0000,
                      url='' if link is None else link)
        embed.set_footer(text=self._STATUS_LEGEND)

        height = math.ceil(
            len(status_report) / float(Limits.EMBED_INLINE_FIELD_LIMIT))

        for _ in range(height * Limits.EMBED_INLINE_FIELD_LIMIT):
            embed.add_field(name=embedutils.BLANK_DATA,
                            value=embedutils.BLANK_DATA)

        r = 0
        c = 0
        for i in range(len(status_report)):
            if len(status_report[i + 1][0]) == 1:
                status_display = 'Complete!'
            else:
                status_display = ''
                for time, status in status_report[i + 1]:
                    status_display += f'{time} | {status}\n'
                if len(status_display) == 0:
                    status_display = embedutils.BLANK_DATA

            embed.set_field_at(r * Limits.EMBED_INLINE_FIELD_LIMIT + c,
                               name=f'Part {i + 1}',
                               value=status_display)

            r = (r + 1) % height
            if r == 0:
                c += 1

        await ctx.send(embed=embed)
 async def _help_embed(self,
                       title: str,
                       description: Optional[str] = None,
                       mapping: Optional[str] = None,
                       command_set: Optional[Set[commands.Command]] = None,
                       set_author: bool = False) -> Embed:
     embed = Embed(title=title)
     if description:
         embed.description = description
     if set_author:
         avatar = self.context.bot.user.avatar or self.context.bot.user.default_avatar
         embed.set_author(name=self.context.bot.user.name,
                          icon_url=avatar.url)
     if command_set:
         # show help about all commands in the set
         filtered = await self.filter_commands(command_set, sort=True)
         for command in filtered:
             embed.add_field(name=self.get_command_signature(command),
                             value=command.short_doc or "...",
                             inline=False)
     elif mapping:
         # add a short description of commands in each cog
         for cog, command_set in mapping.items():
             filtered = await self.filter_commands(command_set, sort=True)
             if not filtered:
                 continue
             name = cog.qualified_name if cog else "No category"
             emoji = getattr(cog, "COG_EMOJI", None)
             cog_label = f"{emoji} {name}" if emoji else name
             # \u2002 is an en-space
             cmd_list = "\u2002".join(
                 f"`{self.context.clean_prefix}{cmd.name}`"
                 for cmd in filtered)
             value = (f"{cog.description}\n{cmd_list}"
                      if cog and cog.description else cmd_list)
             embed.add_field(name=cog_label, value=value)
     return embed
 async def slots(self, ctx):
     emojilist = [
         '<:sipsScared:819393684549533716>',
         '<:passMan:256140704806338560>', '<:fireball:267121761173110784>',
         '<:gabeN:255489512543748097>', '<:doug:337020649753018368>',
         '<:ripley:532377971009257492> ', '<:alex:338163624063533056>'
     ]
     slotboard = []
     slotembed = Embed(title='SadDoug Slots', color=0xa2afb8)
     for x in range(9):
         slotboard.append(random.choice(emojilist))
     slotembed.add_field(
         name='\u200b',
         value=':stop_button:' + slotboard[0] +
         ':eight_pointed_black_star::eight_pointed_black_star::stop_button:\n :arrow_forward:'
         + slotboard[3] +
         ':eight_pointed_black_star::eight_pointed_black_star::arrow_backward:\n:stop_button:'
         + slotboard[6] +
         ':eight_pointed_black_star::eight_pointed_black_star::stop_button:',
         inline=False)
     message = await ctx.send(embed=slotembed)
     await asyncio.sleep(1)
     slotembed = Embed(title='SadDoug Slots', color=0xa2afb8)
     slotembed.add_field(
         name='\u200b',
         value=':stop_button:' + slotboard[0] + ' ' + slotboard[1] +
         ':eight_pointed_black_star:' + ':stop_button:\n :arrow_forward:' +
         slotboard[3] + ' ' + slotboard[4] + ':eight_pointed_black_star:' +
         ':arrow_backward:\n:stop_button:' + slotboard[6] + ' ' +
         slotboard[7] + ':eight_pointed_black_star:' + ':stop_button:',
         inline=False)
     await message.edit(embed=slotembed)
     await asyncio.sleep(1)
     slotembed = Embed(title='SadDoug Slots', color=0xa2afb8)
     slotembed.add_field(
         name='\u200b',
         value=':stop_button:' + slotboard[0] + ' ' + slotboard[1] + ' ' +
         slotboard[2] + ':stop_button:\n :arrow_forward:' + slotboard[3] +
         ' ' + slotboard[4] + ' ' + slotboard[5] +
         ':arrow_backward:\n:stop_button:' + slotboard[6] + ' ' +
         slotboard[7] + ' ' + slotboard[8] + ':stop_button:',
         inline=False)
     await message.edit(embed=slotembed)
     if slotboard[3] is slotboard[4] is slotboard[5]:
         await message.edit(content='Winner')
     else:
         await message.edit(content='Try again')
Beispiel #19
0
    async def update_attachments(self, _, interaction: Interaction):
        embed = Embed(
            title=f"Update {self.product['name']}",
            description=f'Please post the attachments now. Say "Done" when you are done.',
            colour=Colour.blue(),
            timestamp=nextcord.utils.utcnow(),
        )

        embed.set_footer(
            text='Redon Tech RPH • Say "Cancel" to cancel. • By: parker02311'
        )

        fields = [
            (
                "Attachments",
                "None",
                False,
            )
        ]

        for name, value, inline in fields:
            embed.add_field(name=name, value=value, inline=inline)

        view = CancelView(self.context)
        await interaction.message.edit("", embed=embed, view=None)

        def check(m):
            return m.author == self.context.author

        attachments = []

        while True:
            try:
                message = await self.bot.wait_for("message", timeout=600.0, check=check)
            except TimeoutError:
                await interaction.message.delete()
                await interaction.response.send_message("Timed Out", ephemeral=True)
                self.stop()

            if message.content.lower() == "cancel":
                await interaction.message.delete()
                await self.context.send(
                    "Canceled", reference=self.context.message, delete_after=5.0
                )

                break
            if message.content.lower() == "done":
                break
            elif not message.attachments == [] and message.attachments:
                for attachment in message.attachments:
                    attachments.append(attachment.url)
                    embed = Embed(
                        title=f"Update {self.product['name']}",
                        description=f'Please post the attachments now. Say "Done" when you are done.',
                        colour=Colour.blue(),
                        timestamp=nextcord.utils.utcnow(),
                    )

                    embed.set_footer(
                        text='Redon Tech RPH • Say "Cancel" to cancel. • By: parker02311'
                    )

                    fields = [
                        (
                            "Attachments",
                            "\n".join([attachment for attachment in attachments]),
                            False,
                        )
                    ]

                    for name, value, inline in fields:
                        embed.add_field(name=name, value=value, inline=inline)

                    embed.set_footer(text="Pembroke Bot • By: parker02311")
                    await interaction.message.edit("", embed=embed, view=None)
                    await self.context.send(
                        "It is recommended to not delete this message unless needed.",
                        reference=message,
                    )

        if attachments:
            await interaction.message.delete()
            view = AreYouSureView(self.context)
            await self.context.send(
                f"Are you sure you would like to change {self.product['attachments']} to {attachments}?",
                view=view,
                reference=self.context.message,
            )
            await view.wait()

            if view.Return == None:
                await message.delete()
                await interaction.response.send_message("Timed out", ephemeral=True)
            elif view.Return == False:
                await message.delete()
                await interaction.response.send_message("Canceled update", ephemeral=True)
            elif view.Return == True:
                try:
                    updateproduct(
                        self.product["name"], self.product["name"], self.product["description"], self.product["price"], attachments
                    )
                    await interaction.message.delete()
                    name = self.product["name"]
                    await interaction.response.send_message(
                        f"Updated {name}.",
                        ephemeral=True,
                    )
                except:
                    await interaction.message.delete()
                    await interaction.response.send_message(
                        f"Failed to update {self.args[0]}.",
                        ephemeral=True,
                    )
Beispiel #20
0
    async def detailedstats(self, ctx):
        pet = PetHandler.getcurrentpet()
        embed = Embed(title='<:clownS:819397835636080640> Name: ' + str(pet['name'] + ' <:clownS:819397835636080640>'), color=0x228B22)
        embed.add_field(name='Health', value=str(pet['currenthealth']) + '/' + str(pet['maxhealth']), inline=True)
        embed.add_field(name='Food', value=str(pet['food']) + '/100', inline=True)
        embed.add_field(name='Water', value=str(pet['water']) + '/100', inline=True)
        embed.add_field(name='Cleanliness', value=str(pet['cleanliness']) + '/100', inline=True)
        embed.add_field(name='Happiness', value=str(pet['happiness']) + '/100', inline=True)

        embed.add_field(name='Birthday', value=str(pet['birthdate']), inline=True)
        embed.add_field(name='Last Checked', value=str(pet['lastchecked']), inline=True)
        embed.add_field(name='Last Fed', value=str(pet['lastfeed']), inline=True)
        embed.add_field(name='Last Watered', value=str(pet['lastwatered']), inline=True)
        embed.add_field(name='Last Cleaned', value=str(pet['lastcleaned']), inline=True)
        embed.add_field(name='Last Pet', value=str(pet['lastpet']), inline=True)

        embed.add_field(name='Type:', value=str(pet['type']), inline=True)
        embed.add_field(name='Level', value=str(pet['level']), inline=True)
        embed.add_field(name='Attack', value=str(pet['attack']), inline=True)
        embed.add_field(name='Defence', value=str(pet['defence']), inline=True)
        await ctx.send(embed=embed)
Beispiel #21
0
    async def attachment_filter(self, message):
        """When a message is sent by normal users ensure it doesn't have any non-image attachments. Delete it and send
        a mod message if it does."""
        if message.author.bot:
            return

        if not message.attachments:
            return

        if os.environ.get("PRODUCTION_BOT", False):
            if message.channel.name.lower() in self.admin_channels:
                return

            if message.channel.permissions_for(message.author).manage_messages:
                return

        allowed, disallowed = self.categorize_attachments(message)

        if not allowed and not disallowed:
            return

        user_message = ("\n".join(f"> {section}"
                                  for section in message.content.split("\n"))
                        if message.content.strip() else "")
        embed = Embed(
            title="File Attachments Not Allowed",
            description=
            f"For safety reasons we do not allow file and video attachments.",
            color=YELLOW,
        )

        if allowed:
            embed.title = f"{message.author.display_name} Uploaded Some Code"
            embed.description = user_message
            files = {}
            name = None
            for attachment in allowed:
                content = (await attachment.read()).decode()
                if len(content) < 1000:
                    file_type = os.path.splitext(
                        attachment.filename)[1].casefold()
                    embed.add_field(
                        name=f"Attachment: {attachment.filename}",
                        value=
                        f"```{self.file_types.get(file_type, '')}\n{content}\n```",
                    )
                else:
                    if not name:
                        name = attachment.filename
                    files[attachment.filename] = content

            if files:
                gist = self.upload_files(files)
                embed.add_field(
                    name="Uploaded the file to a Gist",
                    value=f"[{name}]({gist})",
                )

            embed.set_thumbnail(
                url=
                "https://cdn.discordapp.com/emojis/711749954837807135.png?v=1")

            embed.set_footer(
                text="For safety reasons we do not allow file attachments.")

        else:
            embed.set_thumbnail(
                url=
                "https://cdn.discordapp.com/emojis/651959497698574338.png?v=1")
            if user_message:
                embed.add_field(name=f"{message.author.display_name} Said",
                                value=user_message)
            embed.add_field(
                name="Code Formatting",
                value=
                f"You can share your code using triple backticks like this:\n\\```\nYOUR CODE\n\\```",
                inline=False,
            )
            embed.add_field(
                name="Large Portions of Code",
                value=
                f"For longer scripts use [Hastebin](https://hastebin.com/) or "
                f"[GitHub Gists](https://gist.github.com/) and share the link here",
                inline=False,
            )

        if disallowed:
            embed.add_field(
                name="Ignored these files",
                value="\n".join(f"- {attachment.filename}"
                                for attachment in disallowed) or "*NO FILES*",
            )

        try:
            await message.delete()
        except nextcord.errors.NotFound:
            pass

        await message.channel.send(message.author.mention, embed=embed)
    async def race(listofracers, message):
        tracklength = 10
        movespeedstat = 0
        movechancestat = 0
        embed = Embed(color=0x228B22)
        raceremojilist = []
        racerpositionlist = []
        winner = ['none', 0]
        roundtimer = 0
        overtimeround = 20
        specialtraitslist = []

        # initalboardsetup
        for x, racer in enumerate(listofracers):
            # assign random emoji to racer
            selectedemojiobject = MinigameCommands.randomemoji(
                raceremojilist, movechancestat, movespeedstat,
                specialtraitslist)
            raceremojilist.append(selectedemojiobject[0])

            # update the overal move/chance stats
            movechancestat = selectedemojiobject[1]
            movespeedstat = selectedemojiobject[2]

            # update special traits list
            specialtraitslist = selectedemojiobject[3]

            # apply special traits
            if 'protection' in specialtraitslist:
                movechancestat = 0
                movespeedstat = 0

            # set racer position at starting line
            racerpositionlist.append(1)

            msgcontentline = MinigameCommands.calnumberbehind(
                racerpositionlist[x], tracklength
            ) + raceremojilist[x]['emoji'] + MinigameCommands.calnumberahead(
                racerpositionlist[x], tracklength)

            # if it is a bot we just pass the string, if not the user object
            if type(racer) is str:
                embed.add_field(name=racer, value=msgcontentline, inline=False)
            else:
                embed.add_field(name=racer.name,
                                value=msgcontentline,
                                inline=False)

        await message.edit(content='Go! Go! Go!\n Round: ' + str(roundtimer) +
                           '\nMovespeed stat: ' + str(movespeedstat) +
                           '\nMovechance stat: ' + str(movechancestat),
                           embed=embed)

        # racing
        while MinigameCommands.raceongoing:

            roundtimer += 1

            if roundtimer > overtimeround:
                movechancestat += 1
                movespeedstat += 1

            await message.edit(content='Round: ' + str(roundtimer) +
                               '\nMovespeed stat: ' + str(movespeedstat) +
                               '\nMovechance stat: ' + str(movechancestat),
                               embed=embed)

            # reset embed
            embed = Embed(color=0x228B22)

            for x, racer in enumerate(listofracers):
                moveroll = random.uniform(0, 10)
                movechance = raceremojilist[x]['movechance'] + movechancestat
                # movechance adjustment
                if movechance < 0:
                    movechance = .1
                if moveroll <= movechance:
                    movement = random.uniform(
                        raceremojilist[x]['minmove'],
                        raceremojilist[x]['maxmove'] + movespeedstat)
                    # movement adjustment
                    if movement < 0:
                        movement = 0
                else:
                    movement = 0
                racerpositionlist[x] = racerpositionlist[x] + movement
                # check for race win
                if racerpositionlist[x] >= 10:
                    MinigameCommands.raceongoing = False
                    winner = racer
                    emoji = raceremojilist[x]
                msgcontentline = MinigameCommands.calnumberbehind(
                    racerpositionlist[x], tracklength) + raceremojilist[x][
                        'emoji'] + MinigameCommands.calnumberahead(
                            racerpositionlist[x], tracklength)
                if type(racer) is str:
                    embed.add_field(name=racer,
                                    value=msgcontentline,
                                    inline=False)
                else:
                    embed.add_field(name=racer.name,
                                    value=msgcontentline,
                                    inline=False)

            await message.edit(embed=embed)
            await asyncio.sleep(2)

        if type(winner) is str:
            await message.edit(content='Winner: ' + winner + '\n ' +
                               emoji['emoji'] + ': ' + emoji['quote'] +
                               '\n \u200b',
                               embed=None)
        else:
            await message.edit(content='Winner: ' + winner.mention + '\n ' +
                               emoji['emoji'] + ': ' + emoji['quote'] +
                               '\n \u200b',
                               embed=None)
        MinigameCommands.recordstats(emoji, raceremojilist)
Beispiel #23
0
def _testing_embed():
    embed = Embed(title="Title", url="https://cog-creators.github.io/discord-embed-sandbox/", description="Description", color=0xff0000)
    embed.set_author(name="Author name")
    embed.add_field(name="Field Name", value="Field Value", inline=False)
    embed.set_footer(text="Footer")
    return embed
Beispiel #24
0
    async def _lookup(
        self,
        ctx: Interaction,
        profile: str = SlashOption(
            name="profile",
            description=
            "The osu! profile you are looking up. This can be their username or ID.",
            required=False,
            default=None),
        mode: str = SlashOption(
            name="mode",
            description=
            "The osu! gamemode you want to look up. This can be osu!, osu!taiko, osu!catch, or osu!mania.",
            required=False,
            default=None)):
        # defer
        await ctx.response.defer(ephemeral=False)

        # user has linked account
        if not profile:
            # check if member has an osu! profile linked
            member = await self.bot.db.fetch(
                "SELECT * FROM osulink WHERE discordid = %s", ctx.user.id)
            if not member:
                return await ctx.send(
                    "You don't have a osu! profile linked!\nLink one with **/osu link** or specifiy a username when using **/osu lookup**!",
                    ephemeral=True)

            # specified mode; get data
            if mode:
                if mode not in self.VALID_MODES:
                    return await ctx.send(
                        "Invalid mode selection!\nValid modes are: **osu!**, **osu!taiko**, **osu!catch**, **osu!mania**.",
                        ephemeral=True)

                # TODO: handle this better
                try:
                    user = self.bot.osu.user(member.get("osuid"),
                                             self.TO_API_CONV.get(mode))
                except:
                    return await ctx.send(
                        "Failed to contact the osu!api. Please try again.",
                        ephemeral=True)

            # unspecified mode; use favoritemode
            else:
                # TODO: handle this better
                try:
                    user = self.bot.osu.user(member.get("osuid"),
                                             member.get("favoritemode"))
                except:
                    return await ctx.send(
                        "Failed to contact the osu!api. Please try again.",
                        ephemeral=True)

                mode = self.FROM_API_CONV.get(member.get("favoritemode"))

        # profile used; no mode
        elif profile and not mode:
            # fetch user
            try:
                favoritemode = self.bot.osu.user(profile).playmode
                user = self.bot.osu.user(profile, favoritemode)
            except ValueError:
                return await ctx.send(
                    "I couldn't find that osu! profile!\nMake sure you spelled their **username** or entered their **ID** correctly!",
                    ephemeral=True)
            except:
                return await ctx.send(
                    "An unknown error occured! Please report it to the developer!",
                    ephemeral=True)

            # convert osu!api mode to fancy mode
            mode = self.FROM_API_CONV.get(favoritemode)
        # profile and mode used
        else:
            # check for user error
            if mode not in self.VALID_MODES:
                return await ctx.send(
                    "Invalid mode selection!\nValid modes are: **osu!**, **osu!taiko**, **osu!catch**, **osu!mania**.",
                    ephemeral=True)

            # fetch user
            try:
                user = self.bot.osu.user(profile, self.TO_API_CONV.get(mode))
            except ValueError:
                return await ctx.send(
                    "I couldn't find that osu! profile!\nMake sure you spelled their **username** or entered their **ID** correctly!",
                    ephemeral=True)
            except:
                return await ctx.send(
                    "An unknown error occured! Please report it to the developer!",
                    ephemeral=True)

        # embed
        embed = Embed(
            title=
            f":flag_{user.country_code.lower()}: {':heartpulse:' if user.is_supporter else ''}{':wrench:' if user.is_bot else ''} {user.username} | {mode}",
            color=int(hex(int(user.profile_colour.strip("#"), 16)), 0)
            if user.profile_colour else 0xff94ed)
        embed.set_thumbnail(url=f"https://a.ppy.sh/{user.id}")

        # user doesn't have statistics for requested gamemode
        if not user.statistics.global_rank:
            embed.add_field(
                name=f"No {mode} stats are available for {user.username}.",
                value="** **",
                inline=True)
        # user has statistics for requested gamemode
        else:
            embed.add_field(name="Global Rank",
                            value=f"{user.statistics.global_rank:,}",
                            inline=True)
            embed.add_field(name="Country Rank",
                            value=f"{user.statistics.country_rank:,}",
                            inline=True)
            embed.add_field(name="PP",
                            value=f"{user.statistics.pp:,.2f}",
                            inline=True)
            embed.add_field(name="Ranked Score",
                            value=f"{user.statistics.ranked_score:,}",
                            inline=True)
            embed.add_field(name="Total Score",
                            value=f"{user.statistics.total_score:,}",
                            inline=True)
            embed.add_field(name="Accuracy",
                            value=f"{user.statistics.hit_accuracy:.2f}%",
                            inline=True)
            embed.add_field(name="Play Count",
                            value=f"{user.statistics.play_count:,}",
                            inline=True)

        embed.set_footer(
            text=f"running Moé v{self.bot.version}",
            icon_url="https://bot.its.moe/assets/favicon/favicon-16x16.png")
        if config.debug:
            log(f"Osu: Got api data: {user.username} ({user.id})", Ansi.LGREEN)
        return await ctx.send(embed=embed)
Beispiel #25
0
    async def createproduct(self, ctx):
        questions = [
            "What do you want to call this product?",
            "What do you want the description of the product to be?",
            "What do you want the product price to be?",
            "attachments",
        ]
        embedmessages = []
        usermessages = []
        awnsers = []
        attachments = []

        def check(m):
            return m.content and m.author == ctx.author

        def emojicheck(self, user):
            return user == ctx.author

        def attachmentcheck(m):
            return m.author == ctx.author

        for i, question in enumerate(questions):
            if question == "attachments":
                embed = Embed(
                    title=f"Create Product (Question {i+1})",
                    description='Please post any attachments\nSay "Done" when complete',
                    colour=ctx.author.colour,
                    timestamp=nextcord.utils.utcnow(),
                )

                embed.set_footer(
                    text='Redon Tech RPH • Say "Cancel" to cancel. • By: parker02311'
                )

                fields = [
                    (
                        "Attachments",
                        "None",
                        False,
                    )
                ]

                for name, value, inline in fields:
                    embed.add_field(name=name, value=value, inline=inline)

                embedmessage = await ctx.send(embed=embed)
                embedmessages.append(embedmessage)
                while True:
                    try:
                        message = await self.bot.wait_for(
                            "message", timeout=200.0, check=attachmentcheck
                        )
                    except TimeoutError:
                        await ctx.send("You didn't answer the questions in Time")
                        return
                    if message.content.lower() == "cancel":
                        usermessages.append(message)
                        for message in embedmessages:
                            await message.delete()

                        for message in usermessages:
                            await message.delete()

                        await ctx.message.delete()
                        await ctx.send("Canceled", delete_after=5.0)

                        break
                    if message.content.lower() == "done":
                        usermessages.append(message)
                        break
                    elif not message.attachments == [] and message.attachments:
                        for attachment in message.attachments:
                            attachments.append(attachment.url)
                            embed = Embed(
                                title=f"Create Product (Question {i+1})",
                                description='Please post any attachments\nSay "Done" when complete',
                                colour=ctx.author.colour,
                                timestamp=nextcord.utils.utcnow(),
                            )

                            embed.set_footer(
                                text='Redon Tech RPH • Say "Cancel" to cancel. • By: parker02311'
                            )

                            fields = [
                                (
                                    "Attachments",
                                    "\n".join(
                                        [attachment for attachment in attachments]
                                    ),
                                    False,
                                )
                            ]

                            for name, value, inline in fields:
                                embed.add_field(name=name, value=value, inline=inline)

                            embed.set_footer(text="Pembroke Bot • By: parker02311")
                            await embedmessage.edit(embed=embed)
                            await ctx.send(
                                "It is recommended to not delete this message unless needed.",
                                reference=message,
                            )
            else:
                embed = Embed(
                    title=f"Create Product (Question {i+1})",
                    description=question,
                    colour=ctx.author.colour,
                    timestamp=nextcord.utils.utcnow(),
                )
                embed.set_footer(
                    text='Redon Tech RPH • Say "Cancel" to cancel. • By: parker02311'
                )
                embedmessage = await ctx.send(embed=embed)
                embedmessages.append(embedmessage)
                try:
                    message = await self.bot.wait_for(
                        "message", timeout=200.0, check=check
                    )
                except TimeoutError:
                    await ctx.send("You didn't answer the questions in Time")
                    return
                if message.content.lower() == "cancel":
                    usermessages.append(message)
                    for message in embedmessages:
                        await message.delete()

                    for message in usermessages:
                        await message.delete()

                    await ctx.message.delete()
                    await ctx.send("Canceled", delete_after=5.0)

                    break
                else:
                    usermessages.append(message)
                    awnsers.append(message.content)

        lastbeforefinal = await ctx.send(
            "Creating final message this may take a moment."
        )

        for message in embedmessages:
            await message.delete()

        for message in usermessages:
            await message.delete()

        embed = Embed(
            title="Confirm Product Creation",
            description="✅ to confirm\n❌ to cancel",
            colour=ctx.author.colour,
            timestamp=nextcord.utils.utcnow(),
        )

        fields = [
            ("Name", awnsers[0], False),
            ("Description", awnsers[1], False),
            ("Price", awnsers[2], False),
            (
                "Attachments",
                "\n".join([attachment for attachment in attachments]),
                False,
            ),
        ]

        for name, value, inline in fields:
            embed.add_field(name=name, value=value, inline=inline)

        embed.set_footer(text="Redon Tech RPH • By: parker02311")
        finalmessage = await ctx.send(embed=embed)
        await finalmessage.add_reaction("✅")
        await finalmessage.add_reaction("❌")
        await lastbeforefinal.delete()

        try:
            reaction, user = await self.bot.wait_for(
                "reaction_add", timeout=200.0, check=emojicheck
            )
        except TimeoutError:
            await ctx.author.send("You didn't respond in time.")
            return

        if str(reaction.emoji) == "✅":
            try:
                createproduct(awnsers[0], awnsers[1], awnsers[2], attachments)
            except:
                await ctx.send(
                    "I was unable to create the product...", delete_after=5.0
                )
                raise

            embed = Embed(
                title="Product Created",
                description="The product was successfully created.",
                colour=ctx.author.colour,
                timestamp=nextcord.utils.utcnow(),
            )

            fields = [
                ("Name", awnsers[0], False),
                ("Description", awnsers[1], False),
                ("Price", awnsers[2], False),
                (
                    "Attachments",
                    "\n".join([attachment for attachment in attachments]),
                    False,
                ),
            ]

            for name, value, inline in fields:
                embed.add_field(name=name, value=value, inline=inline)

            embed.set_footer(text="Redon Tech RPH • By: parker02311")
            await ctx.send(embed=embed)
            await finalmessage.delete()
            await ctx.message.delete()