Merge pull request #9 from iakrules/ping

Updated bot.py and pingCog.py
This commit is contained in:
ishaan 2021-05-18 19:50:23 -04:00 committed by GitHub
commit d1011f3430
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 7 deletions

7
bot.py
View file

@ -5,6 +5,13 @@ from discord.ext import commands
TOKEN = os.environ.get("TOKEN") TOKEN = os.environ.get("TOKEN")
client = commands.Bot(command_prefix= 'd!') client = commands.Bot(command_prefix= 'd!')
@client.event
async def on_ready():
print(f'{client.user.name} is ready.')
# print(f'Bot is in {len(client.guilds)} guilds.')
# print(f'Guilds have {len(client.users)} members.')
await client.change_presence(activity=discord.Streaming(name="Click the link!", url="https://www.youtube.com/watch?v=dQw4w9WgXcQ"))
@client.command() @client.command()
async def load(ctx, extension): async def load(ctx, extension):
client.load_extension(f'cogs.{extension}') client.load_extension(f'cogs.{extension}')

View file

@ -6,15 +6,11 @@ class PingCog(commands.Cog):
def __init__(self, client): def __init__(self, client):
self.client = client self.client = client
# Events
@commands.Cog.listener()
async def on_ready(self):
print('Bot is online.')
# Commands # Commands
@commands.command(aliases=['latency']) @commands.command(aliases=['latency'])
async def ping(self, ctx): async def ping(self, ctx):
await ctx.send(f'Pong! {client.latency}ms') # await ctx.send(f'Pong! {client.latency}ms')
await ctx.send('Pong!')
def setup(client): def setup(client):
client.add_cog(PingCog(client)) client.add_cog(PingCog(client))