Skip to content

Instantly share code, notes, and snippets.

@exitcas
Last active December 18, 2023 21:41
Show Gist options
  • Save exitcas/85c8f0d3bf66337dd571278755de180b to your computer and use it in GitHub Desktop.
Save exitcas/85c8f0d3bf66337dd571278755de180b to your computer and use it in GitHub Desktop.
Cool template for using Cogs.
import os
import discord
from discord.ext import commands
# Under the Unlicense <unlicense.org>
# Made by exitcas
TOKEN = "<token>"
PREFIX = "<prefix>"
DESCRIPTION = "<description>"
COGS_DIR = "cogs"
intents = discord.Intents(
emojis_and_stickers = True,
guild_reactions = True,
members = True,
message_content = True,
messages = True,
invites = True
)
bot = commands.Bot(
command_prefix = PREFIX,
description = "<description>",
allowed_mentions = discord.AllowedMentions(
roles = True,
users = True,
everyone = False
),
intents = intents
)
cog = str()
split_cog = list()
@bot.event
async def setup_hook():
for x in os.listdir(COGS_DIR + "/"):
if x.endswith(".py"):
split_cog = x.split(".")
split_cog.pop(len(split_cog) - 1)
cog = ".".join(split_cog)
await bot.load_extension(COGS_DIR + "." + cog)
@bot.event
async def on_ready():
await bot.tree.sync()
if __name__ == "__main__":
bot.run(TOKEN)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment