or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

commands-interactions.mdcore-clients.mddiscord-objects.mderror-handling.mdextensions.mdindex.mdui-components.mdutilities-helpers.md

extensions.mddocs/

0

# Extensions and Framework

1

2

Extension modules providing command frameworks, hybrid commands, background tasks, and pagination utilities for building sophisticated Discord bots. These extensions offer powerful abstractions and tools for complex bot functionality.

3

4

## Capabilities

5

6

### Commands Extension (discord.ext.commands)

7

8

Comprehensive command framework for prefix-based commands with argument parsing, checks, error handling, and cog organization.

9

10

```python { .api }

11

# Import the commands extension

12

from discord.ext import commands

13

14

class Bot(commands.Bot):

15

"""

16

Enhanced bot class with command processing capabilities.

17

"""

18

19

def __init__(

20

self,

21

command_prefix: Union[str, Callable],

22

*,

23

help_command: Optional[HelpCommand] = None,

24

description: str = None,

25

case_insensitive: bool = False,

26

strip_after_prefix: bool = False,

27

owner_id: int = None,

28

owner_ids: Set[int] = None,

29

**options

30

) -> None:

31

"""

32

Create a commands bot.

33

34

Parameters:

35

- command_prefix: Union[str, Callable] - Prefix for commands

36

- help_command: HelpCommand - Custom help command implementation

37

- description: str - Bot description for help

38

- case_insensitive: bool - Whether commands are case-insensitive

39

- strip_after_prefix: bool - Strip whitespace after prefix

40

- owner_id: int - Bot owner user ID

41

- owner_ids: Set[int] - Set of bot owner user IDs

42

"""

43

44

def command(

45

self,

46

name: str = None,

47

*,

48

cls: Type[Command] = None,

49

**attrs

50

) -> Callable:

51

"""

52

Decorator to create a command.

53

54

Parameters:

55

- name: str - Command name (defaults to function name)

56

- cls: Type[Command] - Command class to use

57

"""

58

59

def group(

60

self,

61

name: str = None,

62

*,

63

cls: Type[Group] = None,

64

**attrs

65

) -> Callable:

66

"""

67

Decorator to create a command group.

68

69

Parameters:

70

- name: str - Group name (defaults to function name)

71

- cls: Type[Group] - Group class to use

72

"""

73

74

async def get_prefix(self, message: Message) -> Union[List[str], str]:

75

"""Get the prefix for a message."""

76

77

async def get_context(

78

self,

79

origin: Union[Message, Interaction],

80

*,

81

cls: Type[Context] = None

82

) -> Context:

83

"""Get the context for a message or interaction."""

84

85

async def invoke(self, ctx: Context) -> None:

86

"""Invoke a command from context."""

87

88

async def process_commands(self, message: Message) -> None:

89

"""Process commands from a message."""

90

91

def add_command(self, command: Command) -> None:

92

"""Add a command to the bot."""

93

94

def remove_command(self, name: str) -> Optional[Command]:

95

"""Remove a command from the bot."""

96

97

def get_command(self, name: str) -> Optional[Command]:

98

"""Get a command by name."""

99

100

@property

101

def commands(self) -> Set[Command]:

102

"""All commands registered to the bot."""

103

104

class AutoShardedBot(Bot):

105

"""Auto-sharded version of the commands bot."""

106

pass

107

108

def command(name: str = None, **kwargs) -> Callable:

109

"""

110

Decorator to create a command outside of a bot class.

111

112

Parameters:

113

- name: str - Command name

114

**kwargs: Command attributes

115

"""

116

117

def group(name: str = None, **kwargs) -> Callable:

118

"""

119

Decorator to create a command group outside of a bot class.

120

121

Parameters:

122

- name: str - Group name

123

**kwargs: Group attributes

124

"""

125

126

class Command:

127

"""

128

Represents a bot command.

129

"""

130

131

def __init__(

132

self,

133

func: Callable,

134

*,

135

name: str = None,

136

aliases: List[str] = None,

137

description: str = None,

138

brief: str = None,

139

usage: str = None,

140

help: str = None,

141

hidden: bool = False,

142

enabled: bool = True,

143

parent: Optional[Group] = None,

144

cog: Optional[Cog] = None,

145

checks: List[Callable] = None,

146

cooldown_after_parsing: bool = False,

147

**kwargs

148

) -> None: ...

149

150

@property

151

def name(self) -> str: ...

152

@property

153

def aliases(self) -> List[str]: ...

154

@property

155

def description(self) -> str: ...

156

@property

157

def brief(self) -> str: ...

158

@property

159

def usage(self) -> str: ...

160

@property

161

def help(self) -> str: ...

162

@property

163

def hidden(self) -> bool: ...

164

@property

165

def enabled(self) -> bool: ...

166

@property

167

def parent(self) -> Optional[Group]: ...

168

@property

169

def cog(self) -> Optional[Cog]: ...

170

@property

171

def checks(self) -> List[Callable]: ...

172

@property

173

def qualified_name(self) -> str: ...

174

@property

175

def signature(self) -> str: ...

176

177

def add_check(self, func: Callable) -> None:

178

"""Add a check to the command."""

179

180

def remove_check(self, func: Callable) -> None:

181

"""Remove a check from the command."""

182

183

async def invoke(self, ctx: Context) -> None:

184

"""Invoke the command."""

185

186

async def can_run(self, ctx: Context) -> bool:

187

"""Check if the command can run in the given context."""

188

189

class Group(Command):

190

"""

191

A command that can contain subcommands.

192

"""

193

194

def __init__(

195

self,

196

*,

197

invoke_without_subcommand: bool = False,

198

case_insensitive: bool = False,

199

**kwargs

200

) -> None: ...

201

202

@property

203

def commands(self) -> Set[Command]: ...

204

@property

205

def invoke_without_subcommand(self) -> bool: ...

206

@property

207

def case_insensitive(self) -> bool: ...

208

209

def command(self, *args, **kwargs) -> Callable:

210

"""Decorator to add a subcommand."""

211

212

def group(self, *args, **kwargs) -> Callable:

213

"""Decorator to add a subgroup."""

214

215

def add_command(self, command: Command) -> None: ...

216

def remove_command(self, name: str) -> Optional[Command]: ...

217

def get_command(self, name: str) -> Optional[Command]: ...

218

219

async def invoke(self, ctx: Context) -> None: ...

220

221

class Context:

222

"""

223

Represents the context for a command invocation.

224

"""

225

226

@property

227

def message(self) -> Message: ...

228

@property

229

def bot(self) -> Bot: ...

230

@property

231

def args(self) -> List[str]: ...

232

@property

233

def kwargs(self) -> Dict[str, Any]: ...

234

@property

235

def prefix(self) -> str: ...

236

@property

237

def command(self) -> Optional[Command]: ...

238

@property

239

def invoked_with(self) -> str: ...

240

@property

241

def invoked_parents(self) -> List[str]: ...

242

@property

243

def invoked_subcommand(self) -> Optional[Command]: ...

244

@property

245

def subcommand_passed(self) -> Optional[str]: ...

246

@property

247

def command_failed(self) -> bool: ...

248

@property

249

def author(self) -> Union[User, Member]: ...

250

@property

251

def guild(self) -> Optional[Guild]: ...

252

@property

253

def channel(self) -> Union[GuildChannel, DMChannel, PartialMessageable]: ...

254

@property

255

def me(self) -> Union[Member, ClientUser]: ...

256

@property

257

def voice_client(self) -> Optional[VoiceProtocol]: ...

258

@property

259

def valid(self) -> bool: ...

260

@property

261

def clean_prefix(self) -> str: ...

262

@property

263

def cog(self) -> Optional[Cog]: ...

264

265

async def invoke(self, command: Command, /, *args, **kwargs) -> None:

266

"""Invoke another command."""

267

268

async def reinvoke(self, *, call_hooks: bool = False, restart: bool = True) -> None:

269

"""Reinvoke the current command."""

270

271

async def send(

272

self,

273

content: str = None,

274

*,

275

tts: bool = False,

276

embed: Embed = None,

277

embeds: List[Embed] = None,

278

file: File = None,

279

files: List[File] = None,

280

view: View = None,

281

reference: Union[Message, MessageReference, PartialMessage] = None,

282

mention_author: bool = None,

283

allowed_mentions: AllowedMentions = None,

284

suppress_embeds: bool = False,

285

ephemeral: bool = False,

286

silent: bool = False,

287

**kwargs

288

) -> Message:

289

"""Send a message to the context channel."""

290

291

async def reply(self, *args, **kwargs) -> Message:

292

"""Reply to the context message."""

293

294

def typing(self) -> Typing:

295

"""Trigger typing indicator in the channel."""

296

```

297

298

### Command Checks and Permissions

299

300

Decorators and functions for controlling command access and execution.

301

302

```python { .api }

303

def check(predicate: Callable[[Context], bool]) -> Callable:

304

"""

305

Decorator to add a check to a command.

306

307

Parameters:

308

- predicate: Callable - Function that returns True if check passes

309

"""

310

311

def check_any(*checks: Callable) -> Callable:

312

"""

313

Require any of the given checks to pass.

314

315

Parameters:

316

*checks: Check functions

317

"""

318

319

def has_role(item: Union[int, str, Role]) -> Callable:

320

"""

321

Check if user has a specific role.

322

323

Parameters:

324

- item: Union[int, str, Role] - Role ID, name, or object

325

"""

326

327

def has_any_role(*items: Union[int, str, Role]) -> Callable:

328

"""

329

Check if user has any of the specified roles.

330

331

Parameters:

332

*items: Role IDs, names, or objects

333

"""

334

335

def has_permissions(**perms) -> Callable:

336

"""

337

Check if user has specific permissions.

338

339

Parameters:

340

**perms: Permission flags to check

341

"""

342

343

def has_guild_permissions(**perms) -> Callable:

344

"""

345

Check if user has guild-level permissions.

346

347

Parameters:

348

**perms: Permission flags to check

349

"""

350

351

def bot_has_role(item: Union[int, str, Role]) -> Callable:

352

"""Check if bot has a specific role."""

353

354

def bot_has_any_role(*items: Union[int, str, Role]) -> Callable:

355

"""Check if bot has any of the specified roles."""

356

357

def bot_has_permissions(**perms) -> Callable:

358

"""Check if bot has specific permissions."""

359

360

def bot_has_guild_permissions(**perms) -> Callable:

361

"""Check if bot has guild-level permissions."""

362

363

def is_owner() -> Callable:

364

"""Check if user is the bot owner."""

365

366

def is_nsfw() -> Callable:

367

"""Check if channel is NSFW."""

368

369

def dm_only() -> Callable:

370

"""Restrict command to DMs only."""

371

372

def guild_only() -> Callable:

373

"""Restrict command to guilds only."""

374

```

375

376

### Cooldowns and Rate Limiting

377

378

System for managing command cooldowns and concurrency limits.

379

380

```python { .api }

381

def cooldown(

382

rate: int,

383

per: float,

384

type: BucketType = BucketType.default

385

) -> Callable:

386

"""

387

Add a cooldown to a command.

388

389

Parameters:

390

- rate: int - Number of times the command can be used

391

- per: float - Time period in seconds

392

- type: BucketType - Cooldown bucket type

393

"""

394

395

def dynamic_cooldown(

396

cooldown: Callable[[Context], Optional[Cooldown]],

397

type: BucketType = BucketType.default

398

) -> Callable:

399

"""

400

Add a dynamic cooldown to a command.

401

402

Parameters:

403

- cooldown: Callable - Function that returns cooldown or None

404

- type: BucketType - Cooldown bucket type

405

"""

406

407

def max_concurrency(

408

number: int,

409

*,

410

per: BucketType = BucketType.default,

411

wait: bool = False

412

) -> Callable:

413

"""

414

Limit concurrent usage of a command.

415

416

Parameters:

417

- number: int - Maximum concurrent uses

418

- per: BucketType - Concurrency bucket type

419

- wait: bool - Whether to wait for availability

420

"""

421

422

class BucketType(Enum):

423

"""Cooldown bucket types."""

424

default = 0

425

user = 1

426

guild = 2

427

channel = 3

428

member = 4

429

category = 5

430

role = 6

431

432

class Cooldown:

433

"""Represents a command cooldown."""

434

435

def __init__(self, rate: int, per: float) -> None: ...

436

437

@property

438

def rate(self) -> int: ...

439

@property

440

def per(self) -> float: ...

441

442

def get_tokens(self, current: float = None) -> int:

443

"""Get available tokens."""

444

445

def get_retry_after(self, current: float = None) -> float:

446

"""Get retry after time."""

447

448

def update_rate_limit(self, current: float = None) -> Optional[float]:

449

"""Update rate limit and get retry after."""

450

451

def reset(self) -> None:

452

"""Reset the cooldown."""

453

454

def copy(self) -> Cooldown:

455

"""Create a copy of the cooldown."""

456

457

class CooldownMapping:

458

"""Maps cooldowns to different entities."""

459

460

def __init__(self, original: Cooldown, type: BucketType) -> None: ...

461

462

def copy(self) -> CooldownMapping: ...

463

def get_bucket(self, message: Message, current: float = None) -> Cooldown: ...

464

def update_rate_limit(self, message: Message, current: float = None) -> Optional[float]: ...

465

466

class MaxConcurrency:

467

"""Limits concurrent command usage."""

468

469

def __init__(self, number: int, *, per: BucketType, wait: bool) -> None: ...

470

471

@property

472

def number(self) -> int: ...

473

@property

474

def per(self) -> BucketType: ...

475

@property

476

def wait(self) -> bool: ...

477

478

def get_key(self, message: Message) -> Any: ...

479

async def acquire(self, message: Message) -> None: ...

480

async def release(self, message: Message) -> None: ...

481

```

482

483

### Argument Conversion

484

485

System for converting command arguments to appropriate types.

486

487

```python { .api }

488

class Converter:

489

"""Base class for argument converters."""

490

491

async def convert(self, ctx: Context, argument: str) -> Any:

492

"""

493

Convert a string argument to the desired type.

494

495

Parameters:

496

- ctx: Context - Command context

497

- argument: str - String argument to convert

498

499

Returns:

500

Any - Converted value

501

"""

502

503

class UserConverter(Converter):

504

"""Convert arguments to User objects."""

505

506

async def convert(self, ctx: Context, argument: str) -> User: ...

507

508

class MemberConverter(Converter):

509

"""Convert arguments to Member objects."""

510

511

async def convert(self, ctx: Context, argument: str) -> Member: ...

512

513

class TextChannelConverter(Converter):

514

"""Convert arguments to TextChannel objects."""

515

516

async def convert(self, ctx: Context, argument: str) -> TextChannel: ...

517

518

class VoiceChannelConverter(Converter):

519

"""Convert arguments to VoiceChannel objects."""

520

521

async def convert(self, ctx: Context, argument: str) -> VoiceChannel: ...

522

523

class CategoryChannelConverter(Converter):

524

"""Convert arguments to CategoryChannel objects."""

525

526

async def convert(self, ctx: Context, argument: str) -> CategoryChannel: ...

527

528

class ForumChannelConverter(Converter):

529

"""Convert arguments to ForumChannel objects."""

530

531

async def convert(self, ctx: Context, argument: str) -> ForumChannel: ...

532

533

class StageChannelConverter(Converter):

534

"""Convert arguments to StageChannel objects."""

535

536

async def convert(self, ctx: Context, argument: str) -> StageChannel: ...

537

538

class ThreadConverter(Converter):

539

"""Convert arguments to Thread objects."""

540

541

async def convert(self, ctx: Context, argument: str) -> Thread: ...

542

543

class GuildChannelConverter(Converter):

544

"""Convert arguments to any GuildChannel object."""

545

546

async def convert(self, ctx: Context, argument: str) -> GuildChannel: ...

547

548

class RoleConverter(Converter):

549

"""Convert arguments to Role objects."""

550

551

async def convert(self, ctx: Context, argument: str) -> Role: ...

552

553

class GuildConverter(Converter):

554

"""Convert arguments to Guild objects."""

555

556

async def convert(self, ctx: Context, argument: str) -> Guild: ...

557

558

class InviteConverter(Converter):

559

"""Convert arguments to Invite objects."""

560

561

async def convert(self, ctx: Context, argument: str) -> Invite: ...

562

563

class EmojiConverter(Converter):

564

"""Convert arguments to Emoji objects."""

565

566

async def convert(self, ctx: Context, argument: str) -> Emoji: ...

567

568

class PartialEmojiConverter(Converter):

569

"""Convert arguments to PartialEmoji objects."""

570

571

async def convert(self, ctx: Context, argument: str) -> PartialEmoji: ...

572

573

class ColourConverter(Converter):

574

"""Convert arguments to Colour objects."""

575

576

async def convert(self, ctx: Context, argument: str) -> Colour: ...

577

578

class ColorConverter(ColourConverter):

579

"""Alias for ColourConverter."""

580

pass

581

582

class GameConverter(Converter):

583

"""Convert arguments to Game activity objects."""

584

585

async def convert(self, ctx: Context, argument: str) -> Game: ...

586

587

class clean_content(Converter):

588

"""

589

Converter for cleaning message content.

590

591

Removes mentions, @everyone, @here, and other Discord formatting.

592

"""

593

594

def __init__(

595

self,

596

*,

597

fix_channel_mentions: bool = False,

598

use_nicknames: bool = True,

599

escape_markdown: bool = False,

600

remove_markdown: bool = False

601

) -> None: ...

602

603

async def convert(self, ctx: Context, argument: str) -> str: ...

604

605

class Greedy:

606

"""

607

Converter wrapper that consumes multiple arguments greedily.

608

609

Usage: def command(self, ctx, *, users: Greedy[Member])

610

"""

611

612

def __init__(self, converter: Any) -> None: ...

613

614

def run_converters(

615

ctx: Context,

616

converter: Any,

617

argument: str,

618

param: inspect.Parameter

619

) -> Any:

620

"""

621

Run the conversion process for an argument.

622

623

Parameters:

624

- ctx: Context - Command context

625

- converter: Any - Converter type or callable

626

- argument: str - Argument to convert

627

- param: Parameter - Parameter information

628

"""

629

```

630

631

### Cog System

632

633

Organization system for grouping commands and event listeners.

634

635

```python { .api }

636

class Cog:

637

"""

638

Base class for command cogs.

639

"""

640

641

def __init_subclass__(cls, **kwargs) -> None: ...

642

643

@property

644

def qualified_name(self) -> str:

645

"""The cog's qualified name."""

646

647

@property

648

def description(self) -> Optional[str]:

649

"""The cog's description."""

650

651

def get_commands(self) -> List[Command]:

652

"""Get all commands in this cog."""

653

654

def get_listeners(self) -> List[Tuple[str, Callable]]:

655

"""Get all event listeners in this cog."""

656

657

async def cog_load(self) -> None:

658

"""Called when the cog is loaded."""

659

660

async def cog_unload(self) -> None:

661

"""Called when the cog is unloaded."""

662

663

def cog_check(self, ctx: Context) -> bool:

664

"""Check that applies to all commands in this cog."""

665

666

async def cog_command_error(self, ctx: Context, error: Exception) -> None:

667

"""Error handler for commands in this cog."""

668

669

async def cog_before_invoke(self, ctx: Context) -> None:

670

"""Called before any command in this cog is invoked."""

671

672

async def cog_after_invoke(self, ctx: Context) -> None:

673

"""Called after any command in this cog is invoked."""

674

675

class CogMeta(type):

676

"""Metaclass for cogs."""

677

pass

678

```

679

680

### Bridge Extension (discord.ext.bridge)

681

682

Hybrid commands that work as both slash commands and traditional prefix commands.

683

684

```python { .api }

685

from discord.ext import bridge

686

687

class Bot(bridge.Bot):

688

"""Bot that supports both slash and prefix commands."""

689

690

def __init__(

691

self,

692

command_prefix: Union[str, Callable],

693

*,

694

debug_guilds: List[int] = None,

695

**options

696

) -> None: ...

697

698

def bridge_command(self, **kwargs) -> Callable:

699

"""Create a hybrid command that works as both slash and prefix."""

700

701

def bridge_group(self, **kwargs) -> Callable:

702

"""Create a hybrid command group."""

703

704

def bridge_command(**kwargs) -> Callable:

705

"""

706

Create a bridge command.

707

708

The decorated function will work as both a slash command and prefix command.

709

"""

710

711

def bridge_group(**kwargs) -> Callable:

712

"""Create a bridge command group."""

713

714

class BridgeContext:

715

"""Base context for bridge commands."""

716

717

@property

718

def bot(self) -> Bot: ...

719

@property

720

def command(self) -> BridgeCommand: ...

721

@property

722

def is_app(self) -> bool:

723

"""Whether this is an application command context."""

724

725

async def respond(self, *args, **kwargs) -> Union[Message, InteractionMessage]: ...

726

async def reply(self, *args, **kwargs) -> Message: ...

727

async def send(self, *args, **kwargs) -> Message: ...

728

async def edit(self, *args, **kwargs) -> Union[Message, InteractionMessage]: ...

729

async def defer(self, *args, **kwargs) -> None: ...

730

731

class BridgeExtContext(BridgeContext):

732

"""Context for prefix command execution."""

733

pass

734

735

class BridgeApplicationContext(BridgeContext):

736

"""Context for slash command execution."""

737

pass

738

739

class BridgeCommand:

740

"""Hybrid command that supports both slash and prefix."""

741

742

@property

743

def name(self) -> str: ...

744

@property

745

def description(self) -> str: ...

746

@property

747

def slash_command(self) -> SlashCommand: ...

748

@property

749

def ext_command(self) -> Command: ...

750

751

def add_to(self, bot: Bot) -> None: ...

752

753

class BridgeOption:

754

"""Option for bridge commands."""

755

756

def __init__(

757

self,

758

input_type: SlashCommandOptionType,

759

description: str,

760

*,

761

name: str = None,

762

**kwargs

763

) -> None: ...

764

765

def bridge_option(name: str, **kwargs) -> Callable:

766

"""Decorator for bridge command options."""

767

```

768

769

### Tasks Extension (discord.ext.tasks)

770

771

Background task scheduling and management system.

772

773

```python { .api }

774

from discord.ext import tasks

775

776

def loop(

777

*,

778

seconds: float = None,

779

minutes: float = None,

780

hours: float = None,

781

time: Union[datetime.time, List[datetime.time]] = None,

782

count: int = None,

783

reconnect: bool = True

784

) -> Callable:

785

"""

786

Decorator to create a background task loop.

787

788

Parameters:

789

- seconds: float - Interval in seconds

790

- minutes: float - Interval in minutes

791

- hours: float - Interval in hours

792

- time: Union[time, List[time]] - Specific time(s) to run

793

- count: int - Number of iterations (None for infinite)

794

- reconnect: bool - Whether to reconnect on network errors

795

"""

796

797

class Loop:

798

"""

799

Represents a background task loop.

800

"""

801

802

def __init__(

803

self,

804

coro: Callable,

805

*,

806

seconds: float = None,

807

minutes: float = None,

808

hours: float = None,

809

time: Union[datetime.time, List[datetime.time]] = None,

810

count: int = None,

811

reconnect: bool = True

812

) -> None: ...

813

814

@property

815

def current_loop(self) -> int:

816

"""Current iteration number."""

817

818

@property

819

def next_iteration(self) -> Optional[datetime]:

820

"""When the next iteration will occur."""

821

822

@property

823

def is_running(self) -> bool:

824

"""Whether the loop is running."""

825

826

@property

827

def failed(self) -> bool:

828

"""Whether the loop has failed."""

829

830

@property

831

def is_being_cancelled(self) -> bool:

832

"""Whether the loop is being cancelled."""

833

834

def start(self, *args, **kwargs) -> None:

835

"""Start the loop."""

836

837

def stop(self) -> None:

838

"""Stop the loop."""

839

840

def cancel(self) -> None:

841

"""Cancel the loop."""

842

843

def restart(self, *args, **kwargs) -> None:

844

"""Restart the loop."""

845

846

def change_interval(

847

self,

848

*,

849

seconds: float = None,

850

minutes: float = None,

851

hours: float = None

852

) -> None:

853

"""Change the loop interval."""

854

855

def before_loop(self, coro: Callable) -> Callable:

856

"""Decorator for function to run before the loop starts."""

857

858

def after_loop(self, coro: Callable) -> Callable:

859

"""Decorator for function to run after the loop ends."""

860

861

def error(self, coro: Callable) -> Callable:

862

"""Decorator for error handler."""

863

```

864

865

### Pages Extension (discord.ext.pages)

866

867

Pagination utilities for creating multi-page messages with navigation.

868

869

```python { .api }

870

from discord.ext import pages

871

872

class Paginator:

873

"""

874

Main paginator for handling multi-page content.

875

"""

876

877

def __init__(

878

self,

879

pages: List[Union[str, Embed, Dict]],

880

*,

881

show_disabled: bool = True,

882

show_indicator: bool = True,

883

author_check: bool = True,

884

disable_on_timeout: bool = True,

885

use_default_buttons: bool = True,

886

default_button_row: int = 0,

887

loop_pages: bool = False,

888

timeout: Optional[float] = 180.0,

889

custom_view: View = None,

890

**kwargs

891

) -> None:

892

"""

893

Create a paginator.

894

895

Parameters:

896

- pages: List - Content for each page

897

- show_disabled: bool - Show disabled navigation buttons

898

- show_indicator: bool - Show page number indicator

899

- author_check: bool - Only allow author to interact

900

- disable_on_timeout: bool - Disable buttons on timeout

901

- use_default_buttons: bool - Use default navigation buttons

902

- default_button_row: int - Row for default buttons

903

- loop_pages: bool - Loop from last page to first

904

- timeout: float - Interaction timeout

905

- custom_view: View - Custom view for additional components

906

"""

907

908

@property

909

def pages(self) -> List[Union[str, Embed, Dict]]: ...

910

@property

911

def current_page(self) -> int: ...

912

@property

913

def page_count(self) -> int: ...

914

915

def add_page(self, page: Union[str, Embed, Dict]) -> None:

916

"""Add a page to the paginator."""

917

918

def remove_page(self, page_number: int) -> None:

919

"""Remove a page from the paginator."""

920

921

def update_page(self, page_number: int, page: Union[str, Embed, Dict]) -> None:

922

"""Update a specific page."""

923

924

async def send(

925

self,

926

destination: Union[Context, Interaction, Messageable],

927

*,

928

ephemeral: bool = False,

929

**kwargs

930

) -> Union[Message, InteractionMessage]:

931

"""Send the paginator."""

932

933

async def edit(

934

self,

935

interaction: Interaction,

936

*,

937

suppress: bool = None

938

) -> InteractionMessage:

939

"""Edit the paginator message."""

940

941

def go_to_page(self, page_number: int) -> None:

942

"""Go to a specific page."""

943

944

def next_page(self) -> None:

945

"""Go to the next page."""

946

947

def previous_page(self) -> None:

948

"""Go to the previous page."""

949

950

class PaginatorButton:

951

"""

952

Navigation button for paginators.

953

"""

954

955

def __init__(

956

self,

957

button_type: str,

958

*,

959

label: str = None,

960

emoji: Union[str, Emoji, PartialEmoji] = None,

961

style: ButtonStyle = ButtonStyle.secondary,

962

disabled: bool = False,

963

custom_id: str = None,

964

row: int = None

965

) -> None: ...

966

967

class PageGroup:

968

"""

969

Group of related pages.

970

"""

971

972

def __init__(

973

self,

974

pages: List[Union[str, Embed, Dict]],

975

label: str,

976

*,

977

description: str = None,

978

emoji: Union[str, Emoji, PartialEmoji] = None,

979

use_default_buttons: bool = True,

980

default_button_row: int = 0,

981

custom_view: View = None

982

) -> None: ...

983

984

@property

985

def label(self) -> str: ...

986

@property

987

def description(self) -> Optional[str]: ...

988

@property

989

def emoji(self) -> Optional[Union[str, Emoji, PartialEmoji]]: ...

990

@property

991

def pages(self) -> List[Union[str, Embed, Dict]]: ...

992

993

class Page:

994

"""

995

Individual page content.

996

"""

997

998

def __init__(

999

self,

1000

*,

1001

content: str = None,

1002

embeds: List[Embed] = None,

1003

files: List[File] = None,

1004

custom_view: View = None

1005

) -> None: ...

1006

1007

@property

1008

def content(self) -> Optional[str]: ...

1009

@property

1010

def embeds(self) -> List[Embed]: ...

1011

@property

1012

def files(self) -> List[File]: ...

1013

@property

1014

def custom_view(self) -> Optional[View]: ...

1015

```

1016

1017

### Prefix Utilities

1018

1019

Helper functions for managing command prefixes.

1020

1021

```python { .api }

1022

def when_mentioned(bot: Bot, message: Message) -> List[str]:

1023

"""

1024

Get prefixes when the bot is mentioned.

1025

1026

Parameters:

1027

- bot: Bot - The bot instance

1028

- message: Message - The message to get prefixes for

1029

1030

Returns:

1031

List[str] - List of mention prefixes

1032

"""

1033

1034

def when_mentioned_or(*prefixes: str) -> Callable[[Bot, Message], List[str]]:

1035

"""

1036

Combine mention prefixes with custom prefixes.

1037

1038

Parameters:

1039

*prefixes: Custom prefixes to add

1040

1041

Returns:

1042

Callable - Function that returns prefixes including mentions

1043

"""

1044

```

1045

1046

The extensions system provides powerful frameworks and utilities for building sophisticated Discord bots with organized command structures, background tasks, interactive pagination, and hybrid command support that works across both traditional and modern Discord interfaces.