2018-03-08 22:47:53 +00:00
|
|
|
import time
|
2018-12-23 13:13:39 +00:00
|
|
|
import config
|
2018-12-23 13:39:26 +00:00
|
|
|
import discord
|
2018-03-08 22:47:53 +00:00
|
|
|
from discord.ext import commands
|
2019-02-28 22:10:30 +00:00
|
|
|
from discord.ext.commands import Cog
|
2018-03-08 22:47:53 +00:00
|
|
|
|
2019-02-28 22:10:30 +00:00
|
|
|
class Basic(Cog):
|
2018-03-08 22:47:53 +00:00
|
|
|
def __init__(self, bot):
|
|
|
|
self.bot = bot
|
|
|
|
|
|
|
|
@commands.command()
|
|
|
|
async def hello(self, ctx):
|
|
|
|
"""Says hello. Duh."""
|
|
|
|
await ctx.send(f"Hello {ctx.author.mention}!")
|
|
|
|
|
2018-12-26 07:48:41 +00:00
|
|
|
@commands.guild_only()
|
2018-12-23 13:39:26 +00:00
|
|
|
@commands.command()
|
|
|
|
async def membercount(self, ctx):
|
|
|
|
"""Prints the member count of the server."""
|
|
|
|
await ctx.send(f"{ctx.guild.name} has "
|
|
|
|
f"{ctx.guild.member_count} members!")
|
|
|
|
|
2018-12-23 17:27:51 +00:00
|
|
|
@commands.command(aliases=["robocopng", "robocop-ng"])
|
|
|
|
async def robocop(self, ctx):
|
|
|
|
"""Shows a quick embed with bot info."""
|
|
|
|
embed = discord.Embed(title="Robocop-NG",
|
|
|
|
url=config.source_url,
|
|
|
|
description=config.embed_desc)
|
|
|
|
|
|
|
|
embed.set_thumbnail(url=self.bot.user.avatar_url)
|
|
|
|
|
|
|
|
await ctx.send(embed=embed)
|
|
|
|
|
2018-03-08 22:47:53 +00:00
|
|
|
@commands.command(aliases=['p'])
|
|
|
|
async def ping(self, ctx):
|
|
|
|
"""Shows ping values to discord.
|
|
|
|
|
|
|
|
RTT = Round-trip time, time taken to send a message to discord
|
|
|
|
GW = Gateway Ping"""
|
|
|
|
before = time.monotonic()
|
|
|
|
tmp = await ctx.send('Calculating ping...')
|
|
|
|
after = time.monotonic()
|
|
|
|
rtt_ms = (after - before) * 1000
|
|
|
|
gw_ms = self.bot.latency * 1000
|
|
|
|
|
2018-12-29 19:09:49 +00:00
|
|
|
message_text = f":ping_pong:\n"\
|
|
|
|
f"rtt: `{rtt_ms:.1f}ms`\n"\
|
|
|
|
f"gw: `{gw_ms:.1f}ms`"
|
2018-03-08 22:47:53 +00:00
|
|
|
self.bot.log.info(message_text)
|
|
|
|
await tmp.edit(content=message_text)
|
|
|
|
|
|
|
|
|
|
|
|
def setup(bot):
|
|
|
|
bot.add_cog(Basic(bot))
|