Skip to content

Commit c656aa4

Browse files
committed
test: Test command for v2 components
1 parent 66caaf8 commit c656aa4

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

main.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import os
44
import uuid
55

6+
from interactions.models.internal.context import SlashContext
7+
68
from thefuzz import process
79

810
import interactions
@@ -69,6 +71,48 @@ async def components(ctx):
6971
)
7072

7173

74+
@slash_command("v2")
75+
async def v2(ctx: SlashContext):
76+
from interactions.models.discord.components import (
77+
SectionComponent,
78+
Button,
79+
TextDisplayComponent,
80+
ContainerComponent,
81+
ButtonStyle,
82+
ActionRow,
83+
SeparatorComponent,
84+
ThumbnailComponent,
85+
UnfurledMediaItem,
86+
)
87+
88+
components = [
89+
SectionComponent(
90+
components=[
91+
TextDisplayComponent("This is some"),
92+
TextDisplayComponent("Text"),
93+
],
94+
accessory=Button(style=ButtonStyle.PRIMARY, label="Click me"),
95+
),
96+
TextDisplayComponent("Hello World"),
97+
ContainerComponent(
98+
ActionRow(
99+
Button(style=ButtonStyle.RED, label="Red Button"), Button(style=ButtonStyle.GREEN, label="Green Button")
100+
),
101+
SeparatorComponent(divider=True),
102+
TextDisplayComponent("👀"),
103+
),
104+
SectionComponent(
105+
components=[
106+
TextDisplayComponent("This one has a thumbnail"),
107+
],
108+
accessory=ThumbnailComponent(
109+
UnfurledMediaItem("https://avatars.githubusercontent.com/u/98242689?s=200&v=4")
110+
),
111+
),
112+
]
113+
await ctx.send(components=components)
114+
115+
72116
@slash_command("record", description="Record audio in your voice channel")
73117
@slash_option("duration", "The duration of the recording", opt_type=interactions.OptionType.NUMBER, required=True)
74118
async def record(ctx: interactions.SlashContext, duration: int) -> None:

0 commit comments

Comments
 (0)