-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a84ca0
commit 8e18672
Showing
5 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import discord | ||
from discord.ext import commands | ||
|
||
class Clear(commands.Cog): | ||
|
||
def __init__(self, bot): self.bot = bot | ||
|
||
@commands.command() | ||
async def clear(self, ctx, num: int): | ||
try: | ||
await ctx.channel.purge(limit=num) | ||
except discord.Forbidden: | ||
await ctx.send("Oops i can't do that rip") | ||
|
||
def setup(bot): | ||
bot.add_cog(Clear(bot)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import discord | ||
from discord.ext import commands | ||
|
||
class Error(commands.Cog): | ||
|
||
def __init__(self, bot): | ||
self.bot = bot | ||
|
||
@commands.Cog.listener() | ||
async def on_command_error(self, ctx, error): | ||
if isinstance(error, commands.BadArgument): | ||
await ctx.send("I only accept numbers smh") | ||
|
||
def setup(bot): | ||
bot.add_cog(Error(bot)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import discord | ||
from discord.ext import commands | ||
|
||
class Hi(commands.Cog): | ||
|
||
def __init__(self, bot: commands.Bot): | ||
self.bot = bot | ||
|
||
@commands.command() | ||
async def ping(self, ctx): | ||
return await ctx.send(f"Pong! :ping_pong: Latency: {round(self.bot.latency*1000, 2)}ms") | ||
|
||
@commands.command() | ||
async def hi(self, ctx, name = None): | ||
name = name or ctx.author.display_name | ||
await ctx.send(f"hello {name}!") | ||
|
||
@commands.command() | ||
async def greet(self, ctx): | ||
await ctx.author.send("Private Greeting oooooooooo") | ||
|
||
@commands.command() | ||
async def sort(self, ctx, *args): | ||
await ctx.send("\n".join(sorted(args))) | ||
|
||
@commands.command() | ||
async def logo(self, ctx): | ||
await ctx.send(file=discord.File("logo.png")) | ||
|
||
def setup(bot): | ||
bot.add_cog(Hi(bot)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import discord | ||
import random | ||
from discord.ext import commands | ||
|
||
class Random(commands.Cog): | ||
|
||
def __init__(self, bot): | ||
self.bot = bot | ||
|
||
@commands.command() | ||
async def flip(self, ctx, count: int): | ||
if count < 0: return await ctx.send("Can't flip a negative number of coins") | ||
if count == 0: return await ctx.send("Well... you flipped nothing so... Nothing") | ||
await ctx.send(" ".join(random.choice(["H", "T"]) for x in range(count))) | ||
|
||
@commands.command() | ||
async def roll(self, ctx, count: int): | ||
print("HERE") | ||
if count < 0: return await ctx.send("Can't roll a negative number of dice") | ||
if count == 0: return await ctx.send("Well... you rolled nothing so... Nothing") | ||
|
||
await ctx.send(" ".join(str(random.randint(1, 6)) for x in range(count))) | ||
|
||
def setup(bot): | ||
bot.add_cog(Random(bot)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import config | ||
import discord | ||
from discord.ext import commands | ||
|
||
class Bot(commands.Bot): | ||
async def on_ready(self): | ||
print(f"READY! Loaded {self.user}") | ||
self.load_extension("cogs.hi") | ||
self.load_extension("cogs.clear") | ||
self.load_extension("cogs.error") | ||
self.load_extension("cogs.random") | ||
|
||
bot = Bot(command_prefix="!") | ||
|
||
bot.run(config.TOKEN) |