Skip to content

Commit d77d549

Browse files
committed
first commit
1 parent 81c53fb commit d77d549

File tree

4 files changed

+49
-1
lines changed

4 files changed

+49
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# python-bot-base-cogs
1+
# python-bot-base-cogs

cogs/test.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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))

config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
settings = {
2+
"token": "", # setup your bot token from https://discord.com/developers
3+
"prefix": "t." # this is prefixfor your bot(not used...)
4+
}

main.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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'])

0 commit comments

Comments
 (0)