Fixed read prefix
First iteration work with cog from slash command
This commit is contained in:
20
cogs/first_cog.py
Normal file
20
cogs/first_cog.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import logging
|
||||
|
||||
from discord.ext import commands
|
||||
|
||||
|
||||
class Test_Cog(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot # defining bot as global var in class
|
||||
|
||||
@commands.Cog.listener() # this is a decorator for events/listeners
|
||||
async def on_ready(self):
|
||||
logging.info(f'Cog {__name__.split(".")[1]} is ready!.')
|
||||
|
||||
@commands.command() # this is for making a command
|
||||
async def ping(self, ctx):
|
||||
await ctx.send(f'Pong! {round(self.bot.latency * 1000)}')
|
||||
|
||||
|
||||
def setup(bot): # a extension must have a setup function
|
||||
bot.add_cog(Test_Cog(bot)) # adding a cog
|
||||
Reference in New Issue
Block a user