Skip to content

sessatakuma/discord-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

discord-bot

A discord bot for our community

Run the bot

  1. You need to setup the following environment variables in your .env file:
    BOT_TOKEN={our_bot_token}
    API_URL={our_url_to_api}
    GOOGLESHEET_ID={our_google_sheet_id}
    GOOGLESHEET_PRIVATE_KEY_ID={our_googlesheet_private_key_id}
    GOOGLESHEET_PRIVATE_KEY={our_googlesheet_private_key}
    GOOGLESHEET_CLIENT_ID={our_googlesheet_client_id}
  2. Go download uv before run the bot with this command:
    uv run bot.py

Create a bot

To create a Discord bot, follow these steps:

  1. Create an application at the Discord Developer Portal.
  2. Navigate to the Bot section on the left panel and get the bot token, then set up your environment variables.
  3. Configure the Default Install Settings in the Installation section:
    • SCOPES
      • applications.commands
      • bot
    • PERMISSIONS
      • Embed Links
      • Mention Everyone
      • Send Messages
      • Use Slash Commands
      • View Channels
  4. Copy the Install Link from above and use it to invite the bot to your server.

Create a command

To create a command, first make a file under /cogs, then append this file name after COGS in config/settings.py:

COGS= [
    "cogs.dict_query",
    ...,
    "cogs.{your_file_name}"
]

Then you can work on implementing the function of that command. Here is the quick template to build your command:

import discord
from discord import app_commands
from discord.ext import commands

from core.bot_core import KumaBot

class YOUR_COMMAND_CLASS(commands.Cog):
    def __init__(self, bot: KumaBot):
        self.bot = bot

    @app_commands.command(name="command", description="xxxxx")
    async def your_command_function(self, interaction: discord.Interaction):
        pass

async def setup(bot: KumaBot):
    await bot.add_cog(YOUR_COMMAND_CLASS(bot))

Check the project

Since the package of ruff and mypy are already installed in dev group, one can directly execute the following command to format and check the project:

ruff format . --check # Check format
ruff check .          # Check linter
mypy .                # Check type

For more detailed setting with IDE (e.g. VScode), please refer to our manual.

About

A discord bot for our community

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages