Giter Site home page Giter Site logo

Comments (3)

1oonie avatar 1oonie commented on May 18, 2024

The reason this was not the api for sending message components in the first place is because the view makes it easier for the developer. I don't find that it isn't convenient to use as well, adding a components kw/arg would serve to confuse, it is better to simply have 1 concrete way of doing something. Also this doesn't look very "convenient" to use

await something.send('Hello, world!', components=[
    ActionRow(
        Button(...)
    )
])

The discord.ui.button decorator makes it very easy to add buttons to a view. (For selects you should probably subclass because it looks ugly otherwise).

In my opinion, the view api is simpler to as you don't have to worry about the boring code that happens behind the scenes.

(Also if you really want to have a components arg you could check out this)

pycord/discord/http.py

Lines 413 to 457 in 8aa1e90

def send_message(
self,
channel_id: Snowflake,
content: Optional[str],
*,
tts: bool = False,
embed: Optional[embed.Embed] = None,
embeds: Optional[List[embed.Embed]] = None,
nonce: Optional[str] = None,
allowed_mentions: Optional[message.AllowedMentions] = None,
message_reference: Optional[message.MessageReference] = None,
stickers: Optional[List[sticker.StickerItem]] = None,
components: Optional[List[components.Component]] = None,
) -> Response[message.Message]:
r = Route('POST', '/channels/{channel_id}/messages', channel_id=channel_id)
payload = {}
if content:
payload['content'] = content
if tts:
payload['tts'] = True
if embed:
payload['embeds'] = [embed]
if embeds:
payload['embeds'] = embeds
if nonce:
payload['nonce'] = nonce
if allowed_mentions:
payload['allowed_mentions'] = allowed_mentions
if message_reference:
payload['message_reference'] = message_reference
if components:
payload['components'] = components
if stickers:
payload['sticker_ids'] = stickers
return self.request(r, json=payload)

from pycord.

siddhpant avatar siddhpant commented on May 18, 2024

On top of that, the interaction response is handled in the view.

Make a factory for yourself, that's what I'm doing.

from pycord.

CodeWithSwastik avatar CodeWithSwastik commented on May 18, 2024

The reason this was not the api for sending message components in the first place is because the view makes it easier for the developer. I don't find that it isn't convenient to use as well, adding a components kw/arg would serve to confuse, it is better to simply have 1 concrete way of doing something. Also this doesn't look very "convenient" to use

await something.send('Hello, world!', components=[
    ActionRow(
        Button(...)
    )
])

The discord.ui.button decorator makes it very easy to add buttons to a view. (For selects you should probably subclass because it looks ugly otherwise).

In my opinion, the view api is simpler to as you don't have to worry about the boring code that happens behind the scenes.

(Also if you really want to have a components arg you could check out this)

pycord/discord/http.py

Lines 413 to 457 in 8aa1e90

def send_message(
self,
channel_id: Snowflake,
content: Optional[str],
*,
tts: bool = False,
embed: Optional[embed.Embed] = None,
embeds: Optional[List[embed.Embed]] = None,
nonce: Optional[str] = None,
allowed_mentions: Optional[message.AllowedMentions] = None,
message_reference: Optional[message.MessageReference] = None,
stickers: Optional[List[sticker.StickerItem]] = None,
components: Optional[List[components.Component]] = None,
) -> Response[message.Message]:
r = Route('POST', '/channels/{channel_id}/messages', channel_id=channel_id)
payload = {}
if content:
payload['content'] = content
if tts:
payload['tts'] = True
if embed:
payload['embeds'] = [embed]
if embeds:
payload['embeds'] = embeds
if nonce:
payload['nonce'] = nonce
if allowed_mentions:
payload['allowed_mentions'] = allowed_mentions
if message_reference:
payload['message_reference'] = message_reference
if components:
payload['components'] = components
if stickers:
payload['sticker_ids'] = stickers
return self.request(r, json=payload)

I agree with this and will close this issue.

from pycord.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.