File tree Expand file tree Collapse file tree 6 files changed +103
-0
lines changed
Expand file tree Collapse file tree 6 files changed +103
-0
lines changed Original file line number Diff line number Diff line change 1+ import discord
2+ from discord .ext import commands
3+
4+ class Clear (commands .Cog ):
5+
6+ def __init__ (self , bot ): self .bot = bot
7+
8+ @commands .command ()
9+ async def clear (self , ctx , num : int ):
10+ try :
11+ await ctx .channel .purge (limit = num )
12+ except discord .Forbidden :
13+ await ctx .send ("Oops i can't do that rip" )
14+
15+ def setup (bot ):
16+ bot .add_cog (Clear (bot ))
Original file line number Diff line number Diff line change 1+ import discord
2+ from discord .ext import commands
3+
4+ class Error (commands .Cog ):
5+
6+ def __init__ (self , bot ):
7+ self .bot = bot
8+
9+ @commands .Cog .listener ()
10+ async def on_command_error (self , ctx , error ):
11+ if isinstance (error , commands .BadArgument ):
12+ await ctx .send ("I only accept numbers smh" )
13+
14+ def setup (bot ):
15+ bot .add_cog (Error (bot ))
Original file line number Diff line number Diff line change 1+ import discord
2+ from discord .ext import commands
3+
4+ class Hi (commands .Cog ):
5+
6+ def __init__ (self , bot : commands .Bot ):
7+ self .bot = bot
8+
9+ @commands .command ()
10+ async def ping (self , ctx ):
11+ return await ctx .send (f"Pong! :ping_pong: Latency: { round (self .bot .latency * 1000 , 2 )} ms" )
12+
13+ @commands .command ()
14+ async def hi (self , ctx , name = None ):
15+ name = name or ctx .author .display_name
16+ await ctx .send (f"hello { name } !" )
17+
18+ @commands .command ()
19+ async def greet (self , ctx ):
20+ await ctx .author .send ("Private Greeting oooooooooo" )
21+
22+ @commands .command ()
23+ async def sort (self , ctx , * args ):
24+ await ctx .send ("\n " .join (sorted (args )))
25+
26+ @commands .command ()
27+ async def logo (self , ctx ):
28+ await ctx .send (file = discord .File ("logo.png" ))
29+
30+ def setup (bot ):
31+ bot .add_cog (Hi (bot ))
Original file line number Diff line number Diff line change 1+ import discord
2+ import random
3+ from discord .ext import commands
4+
5+ class Random (commands .Cog ):
6+
7+ def __init__ (self , bot ):
8+ self .bot = bot
9+
10+ @commands .command ()
11+ async def flip (self , ctx , count : int ):
12+ if count < 0 : return await ctx .send ("Can't flip a negative number of coins" )
13+ if count == 0 : return await ctx .send ("Well... you flipped nothing so... Nothing" )
14+ await ctx .send (" " .join (random .choice (["H" , "T" ]) for x in range (count )))
15+
16+ @commands .command ()
17+ async def roll (self , ctx , count : int ):
18+ print ("HERE" )
19+ if count < 0 : return await ctx .send ("Can't roll a negative number of dice" )
20+ if count == 0 : return await ctx .send ("Well... you rolled nothing so... Nothing" )
21+
22+ await ctx .send (" " .join (str (random .randint (1 , 6 )) for x in range (count )))
23+
24+ def setup (bot ):
25+ bot .add_cog (Random (bot ))
Original file line number Diff line number Diff line change 1+ TOKEN = "ODY2NjQxODMxODg2NzE2OTI4.YPVhGg.gs4sKIc1yEPsSaCGaBE93OU6ENc"
Original file line number Diff line number Diff line change 1+ import config
2+ import discord
3+ from discord .ext import commands
4+
5+ class Bot (commands .Bot ):
6+ async def on_ready (self ):
7+ print (f"READY! Loaded { self .user } " )
8+ self .load_extension ("cogs.hi" )
9+ self .load_extension ("cogs.clear" )
10+ self .load_extension ("cogs.error" )
11+ self .load_extension ("cogs.random" )
12+
13+ bot = Bot (command_prefix = "!" )
14+
15+ bot .run (config .TOKEN )
You can’t perform that action at this time.
0 commit comments