Skip to content

Commit

Permalink
feat(commands.py): add new slash command 'ping' to display latency
Browse files Browse the repository at this point in the history
  • Loading branch information
Mantouisyummy committed Feb 13, 2024
1 parent c4564e3 commit a27e9d7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lava/cogs/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ async def info(self, interaction: ApplicationCommandInteraction):
embed=embed
)

@commands.slash_command(
name=Localized("ping", key="command.ping.name"),
description=Localized("查看機器人延遲", key="command.ping.description")
)
async def ping(self, interaction: ApplicationCommandInteraction):
locale = str(interaction.locale)

await interaction.response.send_message(embed=InfoEmbed(self.bot.get_text("command.ping.title", locale, "機器人延遲"), description=f"{round(self.bot.latency * 1000)}ms"))

@commands.slash_command(
name=Localized("nowplaying", key="command.nowplaying.name"),
description=Localized("顯示目前正在播放的歌曲", key="command.nowplaying.description")
Expand Down
3 changes: 3 additions & 0 deletions locale/zh_TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"command.info.embed.ram": "RAM",
"command.info.embed.guilds": "伺服器數量",
"command.info.embed.players": "播放器數量",
"command.ping.name": "ping",
"command.ping.description": "查看機器人延遲",
"command.ping.title": "機器人延遲",
"command.nowplaying.name": "nowplaying",
"command.nowplaying.description": "顯示目前正在播放的歌曲",
"command.play.name": "play",
Expand Down

0 comments on commit a27e9d7

Please sign in to comment.