Created
December 26, 2020 14:16
-
-
Save Makiyu-py/4999527ed3582e685e072b7302bb2822 to your computer and use it in GitHub Desktop.
First Gist! A really basic ping cmd using discord.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from discord.ext import commands | |
def letteremoji(letter): | |
''' | |
Converts a letter to a discord-syntax (uppercase) emoji | |
Params: | |
letter - the letter you want to convert to a emoji (only works with the latin alphabet) | |
''' | |
return f":regional_indicator_{letter.lower()}:" | |
class PingCommand(commands.Cog): | |
def __init__(self, bot): | |
self.bot = bot | |
# ↓↓↓ Main command here!!! ↓↓↓ | |
@commands.command(description='Checks my latency!') | |
async def ping(self, ctx): | |
await ctx.send(f'{letteremoji("p")} {letteremoji("o")} {letteremoji("n")} {letteremoji("g")} :ping_pong: \n> **{round(self.bot.latency * 1000)}ms**') | |
def setup(bot): | |
bot.add_cog(PingCommand(bot)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment