예제 #1
0
파일: GFLCommands.py 프로젝트: dss285/4Ever
    async def run(self, message: discord.Message, server: Server) -> None:
        parse = self.args.parse(message.content)
        if parse:
            doll = self.find_doll(parse)
            if doll:
                if isinstance(doll, Doll):
                    em = doll.get_embed()
                    image = discord.File(doll.get_image_path(),
                                         filename="doll.png")
                    em.set_image(url="attachment://doll.png")
                    await message.channel.send(file=image, embed=em)
                elif isinstance(doll, list):
                    em = EmbedTemplate(title="Did you mean?",
                                       description="\n".join([
                                           f"{i}. {doll[i-1]}"
                                           for i in range(1,
                                                          len(doll) + 1)
                                       ]))
                    await message.channel.send(embed=em)
                    msg = await self.client.wait_for(
                        'message',
                        check=lambda x: x.author == message.author,
                        timeout=30)
                    if msg:
                        if msg.content.isdigit():
                            tmp = int(msg.content)
                            if 1 <= tmp <= len(doll):
                                chosen_doll = doll[tmp - 1]
                                if chosen_doll in self.database["gfl"][
                                        "dolls"]["names"]:
                                    chosen_doll = self.database["gfl"][
                                        "dolls"]["names"].get(chosen_doll)
                                elif chosen_doll in self.database["gfl"][
                                        "dolls"]["aliases"]:
                                    chosen_doll = self.database["gfl"][
                                        "dolls"]["aliases"].get(chosen_doll)
                                if isinstance(chosen_doll, Doll):
                                    em = chosen_doll.get_embed()
                                    image = discord.File(
                                        chosen_doll.get_image_path(),
                                        filename="doll.png")
                                    em.set_image(url="attachment://doll.png")
                                    await message.channel.send(file=image,
                                                               embed=em)

            else:
                em = EmbedTemplate(
                    title="Not found",
                    description=
                    "Doll wasn't found in the database, if you think this is an error, contact bot owner."
                )
                await message.channel.send(embed=em)
예제 #2
0
 def to_embed(self, ) -> discord.Embed:
     em = EmbedTemplate(title=self.title, description=self.url)
     em.set_image(url=self.image)
     return em
예제 #3
0
def construct_embed(image_url, tags, title) -> discord.Embed:
    em = EmbedTemplate(title=title, description=tags.replace("*", ""))
    em.set_image(url=image_url)
    return em