Skip to content
Discussion options

You must be logged in to vote

Overview

Let's walk through a small example on how to do this, then move onto some resources where you can obtain more information if needed.

from typing import Optional
import discord
from discord.ext import commands


class MyView(discord.ui.View):
    def __init__(self) -> None:
        self.selected: Optional[str] = None
        super().__init__(timeout=180)

    @property
    def content(self) -> str:
        # return the content of the selection.
        # (
        # self.selection or "nothing" means return the selected
        # attribute OR if it's None, return "nothing"
        # )
        return f'You returned {self.selected or "nothing :("}'

    @discord.ui.select(
        pl…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@IhsFace
Comment options

Answer selected by Rapptz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants