gurkult / gurkbot

Our community bot, used for running the server.
MIT License
18 stars 16 forks source link

Util/embed helper #83

Closed vivekashok1221 closed 2 years ago

vivekashok1221 commented 3 years ago

Hello. This PR is by no means the finished feature. I feel the need to discuss some things before proceeding.

Here are some of the things which I feel this PR should address.

vivekashok1221 commented 3 years ago

All arguments except description is optional.

    @command(name="test1")
    async def test1(self, ctx):
        embed = EmbedHelper.error(description="description be like")
        await ctx.send(embed=embed)

image


Other usage:

    @command(name="test2")
    async def test2(self, ctx):
        embed = EmbedHelper.error(title="hey", description=" be like description")
        await ctx.send(embed=embed)

image


    @command(name="test3")
    async def test3(self, ctx):
        embed = EmbedHelper.error(description="link ^", url='https://www.youtube.com/')
        await ctx.send(embed=embed)

image


    @command(name="test4")
    async def test4(self, ctx):
        fields = ({"name": "hi", "value": "bye"}, {"name": "bye", "value": "hi"})
        embed = EmbedHelper.information(title="hi", description="check my fields out", fields=fields)
        await ctx.send(embed=embed)

image


    @command(name="test5")
    async def test5(self, ctx):
        fields = (
            {"name": "hi", "value": "bye", "inline": True},
            {"name": "bye", "value": "hi", "inline": True}
            )
        embed = EmbedHelper.information(description="Fields can be inline", fields=fields)
        await ctx.send(embed=embed)

image

vivekashok1221 commented 3 years ago

I don't think @gustavwilliam (Vestergurkan) is a fan of Embedhelper.category() and prefers the category to be passed in as an argument. I'm free to making changes.

gustavwilliam commented 3 years ago

I don't think @gustavwilliam (Vestergurkan) is a fan of Embedhelper.category() and prefers the category to be passed in as an argument.

Yep. I want it to be dynamic, without having to use getattr if you want to pass the embed type easily.

vivekashok1221 commented 3 years ago
  • [ ] Make the embed deletable or non-deletable based on a no-delete parameter.
  • [ ] Make the embed message mention a role or user specified, or the user invoking the command otherwise.

These features require the message to be sent in the first place. This means that we will need to use a separate helper for sending embeds or subclassing Messagable.send. I am thinking of doing the former. Perhaps I shall subclass discord.Embed and add attributes which specifies which users to mention and whether the embed has to be deleted.

vivekashok1221 commented 3 years ago

I don't think @gustavwilliam (Vestergurkan) is a fan of Embedhelper.category() and prefers the category to be passed in as an argument.

Yep. I want it to be dynamic, without having to use getattr if you want to pass the embed type easily.

By dynamic, I have come to understand that you should be able to do this:

category = "warning" if error else "info"

However, the description has to be passed in too and it will actually end up looking something like

category = "warning" if error else "info"
if category = "warning":
  descripition = "Hi."
else:
  description = "Bye."
embed = embed_helper(description=description)

or

category = "warning" if error else "info"
if category = "warning":
  descripition = "Hi." if category = "warning" else "bye"
embed = embed_helper(description=description)

Therefore, it isn't as dynamic in my eyes.

vivekashok1221 commented 3 years ago

I'm proposing that we shall be able to do the following:

if error:
    embed = EmbedHelper.error("Bye.")
else:
    embed = EmbedHelper.information("Hi.")

rather than

category = "error" if error else "info"
if category = "error":
  descripition = "Bye."
else:
  description = "Hi."
embed = embed_helper(description=description)
gustavwilliam commented 3 years ago

That was simply an example of something you could do. Let's take the gurkanrate as an example. In it, the description will always be the same and the title will change.

It would be nice to just set the title and then automatically get the right embed.

vivekashok1221 commented 3 years ago

That was simply an example of something you could do. Let's take the gurkanrate as an example. In it, the description will always be the same and the title will change.

It would be nice to just set the title and then automatically get the right embed.

The description will still need to be passed in since the helper is a general method and does not know what it will be used for.

gustavwilliam commented 3 years ago

Hi @codephile1221, is there any progress on this?