Boilerplate template for the discord-py-interactions library

Overview

discord-py-interactions_boilerplate

Boilerplate template for the discord-py-interactions library


  • Currently, this boilerplate supports discord-py-interactions==3.0.2 but will be updated for future version later on. To switch to a different version, check the branches

image

Overview

main.py:

  • A custom, dynamic cog loader is present. Write a cog following the template.py in /cogs/, place it in the /cogs/ directory, and it will automatically be loaded when the bot boots.
  • Utilizes the logging library and implements an easy to use custom logger and formatter. All you need to do is call initLogger("script_name") in a module or cog, and log configuration is taken care of for you.
  • Alongside the custom logging utility, exception handling is present and proper debug levels exist. You can configure the level to your liking in config.py. Also, this handles command cooldown if you define it in your cogs.

src/logutil.py:

  • Functions here exist to aid the user in simplifying logging configuration. Here, all log messages go to standard output.
  • A custom formatter also applies based on what level logging you desire, whereas DEBUG produces verbose output and is tailored to aid in debugging, showing which module the message is originating from and, in most cases, which line number. Loggging levels are categorized by color.

cogs/template.py:

  • This example cog is documented extensively. Please be sure to read over it. This cog will not be loaded on boot, so please refrain from writing your code in it.

config.py:

  • This module houses the basic configuration options for your bot, including DEBUG switches and the bot prefix.

Installation

  1. Clone this repository. To switch to a different version, cd into this cloned repository and run git checkout -b [branch name/version here]
  2. Create a Discord bot token from here
    Register it for slash commands:
  • Under OAuth2 > General, set the Authorization Method to "In-app Authorization"
  • Tick bot and applications.commands
  • Go to OAuth2 > URL Generator, tick bot and applications.commands. For Bot Permissions, tick:
  • General: Read Messages/View Channels
  • Text Permissions: Send Messages, Manage Messages, and Embed Links
  • Copy the generated URL at the bottom of the page to invite it to desired servers
  1. Make a new file called .env inside the repo folder and paste the below code block in the file
TOKEN="[paste Discord bot token here]"
DEV_GUILD=[paste your bot testing server ID here]
  1. Run pip install -r requirements.txt to install packages. You'll need Python 3.6.8 or later
  2. Once that's done, run the bot by executing python3 main.py in the terminal

If you aren't sure how to obtain your server ID, check out this article

If you get errors related to missing token environment variables, run source .env

FAQ

Why aren't my slash commands getting registered?

There could be many reasons, but let's narrow it down

  • Ensure your bot token has the applications.command scope before you invited your bot. If not, kick the bot from your server(s), follow above directions to enable the permissions scope, and reinvite.
  • The bot uses a guild ID to register the slash commands in a single guild. This ensures it will be registered instantly. In order to use slash commands globally, remove the guild_ids=[] in your @cog_ext.cog_slash decorators. But keep in mind this may take a few hours to register. To refresh it instantly, simply kick the bot from your server and reinvite.

Why am I getting a HTTP 403 - 50001 Missing Access?

Again, like above, this could be caused by many different reasons, but here are a couple things you can try

  • Follow the above steps to ensure your slash commands are registering properly (making sure applications.command is enabled, etc.)
  • Reinvite your bot
You might also like...
This package allows interactions with the BuyCoins API.

The BuyCoins Python library allows interactions with the BuyCoins API from applications written in Python.

Unit testing AWS interactions with pytest and moto. These examples demonstrate how to structure, setup, teardown, mock, and conduct unit testing. The source code is only intended to demonstrate unit testing.

Unit Testing Interactions with Amazon Web Services (AWS) Unit testing AWS interactions with pytest and moto. These examples demonstrate how to structu

It's a Discord bot to control your PC using your Discord Channel or using Reco: Discord PC Remote Controller App.
It's a Discord bot to control your PC using your Discord Channel or using Reco: Discord PC Remote Controller App.

Reco PC Server Reco PC Server is a cross platform PC Controller Discord Bot which is a modified and improved version of Chimera for Reco-Discord PC Re

Discord bot script for sending multiple media files to a discord channel according to discord limitations.

Discord Bulk Image Sending Bot Send bulk images to Discord channel. This is a bot script that will allow you to send multiple images to Discord channe

MicroStealer - A compact Discord Token Logger/Discord Token Grabber made in only 15 lines of code! Injects into discord for long-term use

๐Ÿ’พ MicroStealer โšก A compact Discord Token Logger/Discord Token Grabber made in o

A template that everyone can use for the start of their discord bot

Python Discord Bot Template This repository is a template that everyone can use for the start of their discord bot. When I first started creating my d

This is a starter template of discord.py project

Template Discord.py This is a starter template of discord.py project (Supports Slash commands!). ๐Ÿ‘€ Getting Started First, you need to install Python

My personal template for a discord bot, including an asynchronous database and colored logging :)
My personal template for a discord bot, including an asynchronous database and colored logging :)

My personal template for a discord bot, including an asynchronous database and colored logging :)

A discord bot with information and template tracking for pxls.space.
A discord bot with information and template tracking for pxls.space.

pyCharity A discord bot with information and template tracking for pxls.space. Inspired by Mikarific's Charity bot. Try out the beta version on your s

Comments
  • feat: Adding ``presence`` for custom bot activity

    feat: Adding ``presence`` for custom bot activity

    About.

    This PR adds presence so custom bot presence (a.k.a activity) can be used.

    Checklist

    • [x] I've ran pre-commit to format and lint the change(s) made.
    • [x] This fixes/solves an Issue. (If existent): https://github.com/interactions-py/boilerplate/issues/8
    • [x] I've made this pull request for/as: (check all that apply)
      • [x] New feature/enhancement
    opened by Jimmy-Blue 2
  • [REQUEST] Implement ``presence`` in ``client`` for custom bot's activity.

    [REQUEST] Implement ``presence`` in ``client`` for custom bot's activity.

    Describe the feature.

    This issue is for the next PR, which is for adding presence in client = interactions.Client so custom activities (a.k.a presences) can be used and acted as an example for bot developers or boilerplate users.

    Code of conduct

    • [x] I agree to follow the contribution requirements.
    opened by Jimmy-Blue 1
  • v4.0.1-unstable

    v4.0.1-unstable

    Changelog

    • Migrates to discord-py-interactions==4.0.1
    • Removes support for message commands, since they are now unsupported
    • Rewrites the dynamic cog loader since cog support has been dropped (temporarily)
    • Adds a streamlined command declaration process while writing in command modules

    Defining:

    self.NAME[str] - What the command responds to
    self.DESCRIPTION[str] - Tells the user what the command does
    self.TYPE[interactions.ApplicationCommandType] - Defaults to CHAT_INPUT
    self.OPTIONS[List[interacions.Option]] - Add command options. Can be None
    

    in __init__() of your command class (see cogs/template.py) fills in the basics for configuring your commands

    • Adds a new permissions checking system (from CommandMC: src/permissions.py) which returns True if a user has specified permissions. See cogs/helloworld.py for example usage
    opened by V3ntus 0
  • v4.0.1 unstable dynamic

    v4.0.1 unstable dynamic "cog" loading

    Since v4 has removed support for cogs and message commands, we have to find an alternative.

    TODO:

    • ~~add a dynamic module loader and decorate manually~~
    • ~~add support for multiple command types (subcommands, buttons, etc.)~~
    • ~~add support for command permissions~~
    • ~~pass the bot: interactions.Client object to each module, or allow them to access it from somewhere~~
    opened by V3ntus 0
Releases(v4.1.1-rc1)
  • v4.1.1-rc1(Apr 17, 2022)

  • v4.1.0(Mar 2, 2022)

    What's Changed

    • Rewrite from v4.1 of interactions.py
    • Introduces the native cog system implemented in interactions.py
    • Bug fixes and more
    • v4.0.1-unstable by @V3ntus in https://github.com/V3ntus/interactions.py-boilerplate/pull/3

    Full Changelog: https://github.com/interactions-py/boilerplate/compare/v4.1.0...v4.1.1-rc1

    Source code(tar.gz)
    Source code(zip)
  • v4.0.1-unstable(Jan 11, 2022)

    Changelog

    #3 :

    • Migrates to discord-py-interactions==4.0.1
    • Removes support for message commands, since they are now unsupported
    • Rewrites the dynamic cog loader since cog support has been dropped (temporarily)
    • Adds a streamlined command declaration process while writing in command modules
    • Adds a new permissions checking system (from CommandMC: src/permissions.py) which returns True if a user has specified permissions. See cogs/helloworld.py for example usage

    Full Changelog: https://github.com/V3ntus/discord-py-interactions_boilerplate/compare/v3.0.2...v4.0.1-unstable

    Release of boilerplate to conform to v4.0.1-unstable of discord-py-interactions

    Source code(tar.gz)
    Source code(zip)
  • v3.0.2(Dec 16, 2021)

    Full Changelog: https://github.com/V3ntus/discord-py-interactions_boilerplate/commits/v3.0.2

    Release of boilerplate to conform to v3.0.2 of discord-py-interactions

    Source code(tar.gz)
    Source code(zip)
Owner
Ventus
Film Composer | Aspiring Cybersecurity Analyst
Ventus
Discord.py-Bot-Template - Discord Bot Template with Python 3.x

Discord Bot Template with Python 3.x This is a template for creating a custom Di

Keagan Landfried 3 Jul 17, 2022
Pincer-bot-template - A template for a Discord bot created using the Pincer library

Pincer Discord Bot Template (Python) WARNING: Pincer is still in its alpha/plann

binds 2 Mar 17, 2022
Discord Panel is an AIO panel for Discord that aims to have all the needed tools related to user token interactions, as in nuking and also everything you could possibly need for raids

Discord Panel Discord Panel is an AIO panel for Discord that aims to have all the needed tools related to user token interactions, as in nuking and al

null 11 Mar 30, 2022
Satoshi is a discord bot template in python using discord.py that allow you to track some live crypto prices with your own discord bot.

Satoshi ~ DiscordCryptoBot Satoshi is a simple python discord bot using discord.py that allow you to track your favorites cryptos prices with your own

Thรฉo 2 Sep 15, 2022
It is a temporary project to study discord interactions. You can set permissions conveniently when you invite a particular disk code bot.

Permission Bot ๋””์Šค์ฝ”๋“œ ๋‚ด์— ์žˆ๋Š” message-components ๋ฅผ ์—ฐ๊ตฌํ•˜๊ธฐ ์œ„ํ•˜์—ฌ ์ œ์ž‘๋œ ๋ด‡์ž…๋‹ˆ๋‹ค. Setup /config/config_example.ini ํŒŒ์ผ์„ /config/config.ini์œผ๋กœ ๋ณ€ํ™˜ํ•ฉ๋‹ˆ๋‹ค. config ํŒŒ์ผ์˜ ๊ธฐ๋ณธ ์–‘์‹์€ ์•„

gunyu1019 4 Mar 7, 2022
A discord http interactions framework built on top of Sanic

snowfin An async discord http interactions framework built on top of Sanic Installing for now just install the package through pip via github # Unix b

kaj 13 Dec 15, 2022
A secure and customizable bot for controlling cross-server announcements and interactions within Discord

DiscordBot A secure and customizable bot for controlling cross-server announcements and interactions within Discord. Within the code of the bot, you c

Jacob Dorfmeister 1 Jan 22, 2022
Useful tools for building interactions in Python

discord-interactions-python Types and helper functions for Discord Interactions webhooks. Installation Available via pypi: pip install discord-interac

Discord 77 Dec 7, 2022
Typed interactions with the GitHub API v3

PyGitHub PyGitHub is a Python library to access the GitHub API v3 and Github Enterprise API v3. This library enables you to manage GitHub resources su

null 5.7k Jan 6, 2023
๐Ÿ“ท Instagram Bot - Tool for automated Instagram interactions

InstaPy Tooling that automates your social media interactions to โ€œfarmโ€ Likes, Comments, and Followers on Instagram Implemented in Python using the Se

Tim GroรŸmann 13.5k Dec 1, 2021