-
Notifications
You must be signed in to change notification settings - Fork 0
/
BasicCommands.py
63 lines (53 loc) · 2.31 KB
/
BasicCommands.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import discord
from discord.ext import commands
from datetime import datetime
class BasicCommands:
def __init__(self, client):
self.client = client
@commands.command(aliases =["p","P"])
@commands.guild_only()
async def ping(self, ctx):
"""gives response time"""
duration = datetime.now() - discord.utils.snowflake_time(ctx.message.id)
ms = duration.microseconds / 1000
embed = discord.Embed(colour = 0x00ff00,
title = "Pong! took `%s ms`" %ms,
description = ctx.guild.name
)
embed.set_author(icon_url = ctx.author.avatar_url, name= str(ctx.author))
embed.set_footer(text = "kenyonJ")
await ctx.send(content = None, embed = embed)
@commands.command(aliases = ["i","I"])
@commands.guild_only()
async def info(self, ctx, *, member: discord.Member):
"""Gives information on user"""
embed = discord.Embed(colour = 0x00ff00,
title = '{0} joined on {0.joined_at} and has {1} role/s.'.format(member, len(member.roles)-1),
description = ctx.guild.name
)
embed.set_author(icon_url = member.avatar_url, name=str(member))
embed.set_footer(text = "KenyonJ")
await ctx.send(content = None, embed = embed)
@commands.command(aliases =["r","R"])
async def repeat(self, ctx, *, arg):
"""repeats what you type"""
await ctx.send(arg)
@commands.command(aliases =["w","W"])
async def wordcount(self, ctx, *args):
"""Counts words in string"""
await ctx.send('{} words'.format(len(args), ', '.join(args)))
@info.error
async def bad_error(self, ctx, error):
if isinstance(error, commands.BadArgument):
await ctx.send('I could not find that member...')
@info.error
async def arg_error(self, ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send("You aren't in a channel!")
@info.error
async def com_error(self, ctx, error):
if isinstance(error, commands.CommandInvokeError):
await ctx.send("You aren't in a channel!")
def setup(bot):
bot.add_cog(BasicCommands(bot))
print("BasicCommands loaded")