Skip to content

Instantly share code, notes, and snippets.

@Makiyu-py
Created December 26, 2020 14:16
Show Gist options
  • Save Makiyu-py/4999527ed3582e685e072b7302bb2822 to your computer and use it in GitHub Desktop.
Save Makiyu-py/4999527ed3582e685e072b7302bb2822 to your computer and use it in GitHub Desktop.
First Gist! A really basic ping cmd using discord.py
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