Example #1
0
    async def poll(self, ctx):
        first = Page(title='Sun vs Moon Poll',
                     description='Do you prefer the sun or the moon?')
        first.set_footer(
            text='Only vote once! Your vote won\'t count if you cheat!')
        first.buttons(['\U00002600', '\U0001F315'])
        first.on_next(self.finish)

        second = Page(title='Sun vs Moon Poll', description=f'Results are in!')

        menu = Poll(ctx).set_timeout(10).add_pages([first, second])
        await menu.open()
Example #2
0
    async def text(self, ctx):

        page1 = Page(
            title='Ping Menu',
            description='Are you absolutely sure you want to send a ping command?',
        )
        page1.set_footer(text='Type `yes` if you are sure.\nType `quit` to cancel this menu.')
        page1.on_next(self.confirm)

        page2 = Page(title='Ping Menu', description='Pong!')

        menu = TextMenu(ctx)
        menu.add_pages([page1, page2])
        menu.normalize_responses()
        await menu.open()
    async def templates2(self, ctx):
        e1 = Page(description='First page test!')

        e2 = Page(title='Page 2',
                  description='Second page test!',
                  color=discord.Color.green())
        e2.add_field(name='Example C', value='Example D')

        e3 = Page(description='Third page test!')
        e3.add_field(name='Example E', value='Example F')
        e3.set_footer(text='A defined footer overrides templates!')

        template = Template(
            title='Template Example Default Title',
            description='This is a default description!',
            color=discord.Color.blue(),
            footer={'text': 'This is a templated footer.'},
            fields=[
                {
                    'name': 'Template Field A',
                    'value': 'Templated field description for A.',
                    'inline': False
                },
                {
                    'name': 'Template Field B',
                    'value': 'Templated field description for B.',
                    'inline': True
                },
            ],
            field_style=FieldStyle.
            COMBINE,  # this will force our template fields to combine with existing fields
            field_sort=FieldSort.
            LAST,  # our template fields will always come after existing fields
        )

        menu = PaginatedMenu(ctx)
        menu.show_command_message()
        menu.add_pages([e1, e2, e3], template=template)
        await menu.open()
Example #4
0
    async def templates(self, ctx):
        e1 = Page(description='First page test!')

        e2 = Page(title='Page 2',
                  description='Second page test!',
                  color=discord.Color.green())
        e2.add_field(name='Example C', value='Example D')

        e3 = Page(description='Third page test!')
        e3.add_field(name='Example E', value='Example F')
        e3.set_footer(text='A defined footer overrides templates!')

        template = Template(
            title='Template Example Default Title',
            description='This is a default description!',
            color=discord.Color.blue(),
            footer={'text': 'This is a templated footer.'},
        )

        menu = PaginatedMenu(ctx)
        menu.show_command_message()
        menu.add_pages([e1, e2, e3], template=template)
        await menu.open()