Skip to content

Commit

Permalink
Format menus guide
Browse files Browse the repository at this point in the history
  • Loading branch information
hypergonial committed Jan 15, 2024
1 parent fc15c1c commit 77ac523
Showing 1 changed file with 7 additions and 21 deletions.
28 changes: 7 additions & 21 deletions docs/guides/menus.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,13 @@ class MainScreen(menu.Screen):
# Note: You should always use @menu decorators
# inside Screen subclasses, NOT @miru
@menu.button(label="Moderation")
async def moderation(
self, , ctx: miru.ViewContext, button: menu.ScreenButton
) -> None:
async def moderation(self, ctx: miru.ViewContext, button: menu.ScreenButton) -> None:
# Add a new screen to the menu stack,
# the message is updated automatically
await self.menu.push(ModerationScreen(self.menu))

@menu.button(label="Logging")
async def fun(
self, ctx: miru.ViewContext, button: menu.ScreenButton
) -> None:
async def fun(self, ctx: miru.ViewContext, button: menu.ScreenButton) -> None:
await self.menu.push(LoggingScreen(self.menu))


Expand All @@ -74,23 +70,17 @@ class ModerationScreen(menu.Screen):
)

@menu.button(label="Back")
async def back(
self, ctx: miru.ViewContext, button: menu.ScreenButton
) -> None:
async def back(self, ctx: miru.ViewContext, button: menu.ScreenButton) -> None:
# Remove the current screen from the menu stack,
# effectively going back to the previous screen
await self.menu.pop()

@menu.button(label="Ban", style=hikari.ButtonStyle.DANGER)
async def ban(
self, ctx: miru.ViewContext, button: menu.ScreenButton
) -> None:
async def ban(self, ctx: miru.ViewContext, button: menu.ScreenButton) -> None:
await ctx.respond("Hammer time!")

@menu.button(label="Kick", style=hikari.ButtonStyle.SECONDARY)
async def kick(
self, ctx: miru.ViewContext, button: menu.ScreenButton
) -> None:
async def kick(self, ctx: miru.ViewContext, button: menu.ScreenButton) -> None:
await ctx.respond("Kick!")


Expand All @@ -112,15 +102,11 @@ class LoggingScreen(menu.Screen):
)

@menu.button(label="Back")
async def back(
self, ctx: miru.ViewContext, button: menu.ScreenButton
) -> None:
async def back(self, ctx: miru.ViewContext, button: menu.ScreenButton) -> None:
await self.menu.pop()

@menu.button(label="Enable", style=hikari.ButtonStyle.DANGER)
async def enable(
self, ctx: miru.ViewContext, button: menu.ScreenButton
) -> None:
async def enable(self, ctx: miru.ViewContext, button: menu.ScreenButton) -> None:
self.is_enabled = not self.is_enabled

if self.is_enabled:
Expand Down

0 comments on commit 77ac523

Please sign in to comment.