APIドキュメント

コンポーネントのイベントを受け取る

class components.ComponentsCog

コンポーネントのイベントを受け取り、ハンドルするコグ。エクステンションとして読み込むには以下のようにして下さい:

bot.load_extension("discord.ext.components")

イベント

on_button_click(com)

ボタンをクリックしたときに発火するイベント。

パラメータ

com (components.ButtonResponse) -- Gatewayからのレスポンス。

on_menu_select(com)

Fires when user selected menu.

パラメータ

com (components.SelectMenuResponse) -- Gatewayからのレスポンス。

コンポーネントのイベントに応答する

class components.ButtonResponse(bot, data, state)

ボタンのイベントです。このクラスを直接初期化しないで下さい。

async defer_source(hidden=False)

DeferredChannelMessageWithSource(5)で応答します。``○○が考え中...``が表示されます。

パラメータ

hidden (bool) -- 応答を隠すかどうか。

async defer_update()

DeferredUpdateMessage(6)で応答します。``○○が考え中...``は表示されません。

パラメータ

hidden (bool) -- 応答を隠すかどうか。

property fired_by

self.member または self.user を返します。

async send(content=None, *, embed=None, embeds=[], allowed_mentions=None, hidden=False, tts=False, components=[])

インタラクションに反応します。

パラメータ
  • content...tts -- ``discord.abc.Messageable.send``と同じです。

  • hidden (bool) -- メッセージを隠すかどうか。

class components.SelectMenuResponse(bot, data, state)

ドロップダウンのイベントです。このクラスを直接初期化しないで下さい。

async defer_source(hidden=False)

DeferredChannelMessageWithSource(5)で応答します。``○○が考え中...``が表示されます。

パラメータ

hidden (bool) -- 応答を隠すかどうか。

async defer_update()

DeferredUpdateMessage(6)で応答します。``○○が考え中...``は表示されません。

パラメータ

hidden (bool) -- 応答を隠すかどうか。

property fired_by

self.member または self.user を返します。

async send(content=None, *, embed=None, embeds=[], allowed_mentions=None, hidden=False, tts=False)

インタラクションに反応します。

パラメータ
  • content...tts -- ``discord.abc.Messageable.send``と同じです。

  • hidden (bool) -- メッセージを隠すかどうか。

property value

Return the first value of values or None.

メッセージをコンポーネント付きで送信する

async components.send(channel, content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, components=[])

メッセージをコンポーネント付きで送信します。

パラメータ
  • channel (discord.abc.Messageable) -- メッセージを送信するチャンネル。

  • content..mention_author -- ``discord.abc.Messageable.send``と同じです。

  • components (list, optional) -- メッセージに追加するコンポーネント。複数行にしたい場合は2次元配列を指定して下さい。

戻り値

送信したメッセージ。

戻り値の型

Message

async components.reply(target, *args, **kwargs)

メッセージへ返信する為の関数。

Components

class components.Button(label: str, custom_id: Optional[str] = None, style: Union[int, components.sender.ButtonType] = ButtonType.primary, url: Optional[str] = None, emoji: Optional[Union[discord.emoji.Emoji, str]] = None, enabled: bool = True, name: Optional[str] = None)

Represents a button in component.

パラメータ
  • label (str) -- Label for the button.

  • custom_id (Optional[str]) -- Custom id for the button.

  • style (Union[int, ButtonType]) -- Style for the button.

  • url (Optional[str]) -- URL for the button.

  • emoji (Union[Emoji, str]) -- Emoji for the button.

  • enabled (bool) -- Weather button is enabled or disabled.

class components.SelectMenu(custom_id: Optional[str], options: List[components.sender.SelectOption], placeholder: Optional[str] = None, min_values: int = 1, max_values: int = 1)

Represents a select menu in component.

パラメータ
  • custom_id (Optional[str]) -- Custom id for the select menu.

  • options (List[SelectOption]) -- Options for the select menu.

  • placeholder (Optional[str]) -- Placeholder for the select menu.

  • min_values (int) -- Minimum number of items that must be chosen.

  • max_values (int) -- Maximum number of items that must be chosen.

class components.SelectOption(label: str, value: str, description: Optional[str] = None, emoji: Optional[Union[discord.emoji.Emoji, str]] = None, default: bool = False)

Represents a option for the select menu.

パラメータ
  • label (str) -- Label for the option.

  • value (str) -- Value for the option.

  • description (Optional[str]) -- Description for the option.

  • emoji (Union[Emoji, str]) -- Emoji for the option.

  • default (bool) -- Weather option is default.

スタイル

class components.ButtonType

ボタンのスタイルを表します。

primary
primary_cta
blue
blurple

スタイル``1``を表します。

secondary
gray
grey

スタイル``2``を表します。

success
primary_success
green

スタイル``3``を表します。

danger
destructive
red

スタイル``4``を表します。

url

スタイル``5``を表します。