Skip to content

Commit fe3096f

Browse files
authored
Update examples.py
1 parent fa8d5d3 commit fe3096f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

examples.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ def get_pointer(obj: typing.Union[discord.Guild, int]):
8787
for p in pointers:
8888
if p.guild.id == obj.id:
8989
return p
90+
pointers.append(Pointer(obj))
9091
return get_pointer(obj)
9192

9293
elif isinstance(obj, int):
@@ -126,6 +127,18 @@ def arrow_button():
126127
return discord.Button(style=discord.ButtonStyle.Primary)
127128

128129

130+
@client.command(name="start_game")
131+
async def start_game(ctx: commands.Context):
132+
pointer: Pointer = get_pointer(ctx.guild)
133+
await ctx.send(embed=discord.Embed(title="Little Game",
134+
description=self.display(x=0, y=0)),
135+
components=[discord.ActionRow(self.empty_button, self.arrow_button.set_label('↑').set_custom_id('up'), self.empty_button),
136+
discord.ActionRow(self.arrow_button.set_label('←').set_custom_id('left').disable_if(pointer.possition_x <= 0), self.arrow_button.set_label('↓').set_custom_id('down').disable_if(pointer.possition_y <= 0), self.arrow_button.set_label('→').set_custom_id('right'))
137+
]
138+
)
139+
140+
141+
@client.event
129142
async def on_raw_interaction_create(interaction: discord.RawInteractionCreateEvent):
130143
await interaction.defer()
131144
pointer: Pointer = get_pointer(interaction.guild)
@@ -164,4 +177,4 @@ async def on_raw_interaction_create(interaction: discord.RawInteractionCreateEve
164177
discord.ActionRow(arrow_button.set_label('←').set_custom_id('left').disable_if(pointer.possition_x <= 0), arrow_button.set_label('↓').set_custom_id('down'), arrow_button.set_label('→').set_custom_id('right'))]
165178
)
166179

167-
client.run('You Bot-Token here')
180+
client.run('You Bot-Token here')

0 commit comments

Comments
 (0)