-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathping.py
More file actions
34 lines (25 loc) · 1.04 KB
/
ping.py
File metadata and controls
34 lines (25 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""Contains cog classes for any ping interactions."""
import random
from typing import TYPE_CHECKING
import discord
from config import settings
from utils import TeXBotBaseCog
if TYPE_CHECKING:
from collections.abc import Sequence
from utils import TeXBotApplicationContext
__all__: "Sequence[str]" = ("PingCommandCog",)
class PingCommandCog(TeXBotBaseCog):
"""Cog class that defines the "/ping" command and its call-back method."""
@discord.slash_command(name="ping", description="Replies with Pong!")
async def ping(self, ctx: "TeXBotApplicationContext") -> None:
"""Definition & callback response of the "ping" command."""
await ctx.respond(
random.choices( # noqa: S311
["Pong!", "`64 bytes from TeX-Bot: icmp_seq=1 ttl=63 time=0.01 ms`"],
weights=(
100 - settings["PING_COMMAND_EASTER_EGG_PROBABILITY"],
settings["PING_COMMAND_EASTER_EGG_PROBABILITY"],
),
)[0],
ephemeral=True,
)