File tree Expand file tree Collapse file tree 4 files changed +49
-1
lines changed Expand file tree Collapse file tree 4 files changed +49
-1
lines changed Original file line number Diff line number Diff line change 1
- # python-bot-base-cogs
1
+ # python-bot-base-cogs
Original file line number Diff line number Diff line change
1
+ # importing libs
2
+ import disnake
3
+ from disnake .ext import commands
4
+
5
+ # creating cog class
6
+ class test (commands .Cog ):
7
+ def __init__ (self , bot ):
8
+ self .bot = bot
9
+ # logging about cog starting(optional)
10
+ @commands .Cog .listener ()
11
+ async def on_ready (self ):
12
+ print ("Cog Test is enabled!" )
13
+
14
+ # creating slash command
15
+ @commands .slash_command (name = "test" , description = "Testing command" )
16
+ async def test (self , inter : disnake .CommandInteraction ):
17
+ await inter .response .send_message ("Test completed" )
18
+
19
+ # init cog
20
+ def setup (bot ):
21
+ bot .add_cog (test (bot ))
Original file line number Diff line number Diff line change
1
+ settings = {
2
+ "token" : "" , # setup your bot token from https://discord.com/developers
3
+ "prefix" : "t." # this is prefixfor your bot(not used...)
4
+ }
Original file line number Diff line number Diff line change
1
+ # importing libs
2
+ import disnake
3
+ from disnake .ext import commands
4
+ from config import settings
5
+ import os
6
+
7
+ # setting up discord bot client
8
+ bot = commands .Bot (command_prefix = f'{ settings ["prefix" ]} ' , intents = disnake .Intents ().all ())
9
+
10
+ # logging about starting bot
11
+ @bot .event
12
+ async def on_ready ():
13
+ print ("bot ready" )
14
+
15
+ #loading cogs from folder
16
+ list_cogs = []
17
+ for filename in os .listdir ("./cogs" ):
18
+ if filename .endswith (".py" ):
19
+ bot .load_extension ("cogs." + filename [:- 3 ])
20
+ list_cogs .append (filename [:- 3 ])
21
+
22
+ # run bot
23
+ bot .run (settings ['token' ])
You can’t perform that action at this time.
0 commit comments