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

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
A results generator and automatic token checker for Yandex Contest

Yandex contest Python checking tools A results generator and automatic token checker for Yandex Contest. Версия на русском языке Installation Clone th

Nikolay Chechulin 9 Dec 14, 2022
A pypi package that helps in generating discord bots.

A pypi package that helps in generating discord bots.

PineCode Corp 3 Nov 17, 2021
Discord bot for Shran development

shranbot A discord bot named Herbert West that will monitor the Shran development discord server. Using dotenv shranbot uses a .env file to load secre

Matt Williams 1 Jul 29, 2022
Generate Heroku-like random names to use in your python applications

HaikunatorPY Generate Heroku-like random names to use in your python applications. Installation pip install haikunator Usage Haikunator is pretty sim

Atrox 116 Nov 15, 2022
Lib for create and show QRCode to PIX, you can show this code in another applications for payment by final consumer.

Biblioteca para a geração de codigos QR (BRCode como chamados na documentação do BACEN) a fins de facilitar a exibição para pagamentos ao consumidor.

João Camargo 13 Oct 05, 2022
Open Source Discord Account Creator

Alter Token Generator Open Source Discord Account Creator This program abuses the discord api and uses the 2Captcha captcha solving service to make di

24 Dec 13, 2022
Tamil Voicechat UserBot. Powerd By TamilBots. Https://T.me/TamilSupport

Tamil Voicechat UserBot A Telegram UserBot to Play music 🎶 in Voice Chats. It's recommended to use an USA number.(if your real number is suspended I'

Tamil Bots 78 Nov 01, 2022
Python client to do LispTick requests

lisptick-python LispTick Python client library It allows to send request and receive result from a LispTick server. Get a socket connection to a LispT

Kereon Intelligence 1 Oct 25, 2021
Music bot for Discord

Treble Music bot for Discord Youtube is after music bots on Discord. So we are here to fill the void. Introducing Treble, the next generation of Disco

Aja Khanal 0 Sep 16, 2022
Python wrapper for Gmailnator

Python wrapper for Gmailnator

h0nda 11 Mar 19, 2022
Send Informative, Concise Slack Notifications With Minimal Effort

slack-templates Send Informative, Concise Slack Notifications With Minimal Effort slack-templates Slack Integration Available Templates Usage Report t

9 Nov 03, 2022
Análise de dados abertos do programa Taxigov.

Análise de dados do Taxigov Este repositório contém os cadernos Jupyter usados no projeto de análise de dados do Taxigov. Conjunto de dados O conjunto

Augusto Herrmann 1 Jan 10, 2022
This is a simple Python bot to identify sentiments in tweets

Twitter-Sentiment 👋 Hi There! 📱 This is a simple Python bot to identify sentiments in tweets 👨‍💻 This project was made for study, and pratice. You

Guilherme Silva 1 Oct 28, 2021
Automate coin farming for dankmemer. Unlimited accounts at once. Uses a proxy

dankmemer-farm Simple script to farm Dankmemer coins with multiple accounts at once. Requires: Proxies, Discord Tokens Disclaimer I don't take respons

Scobra 12 Dec 20, 2022
The Most Simple yet Powerful and Advanced Google Colab Notebook for Zip, Unzip, Tar, UnTar, RaR, UnRaR Files in Google Drive

The Most Simple yet Powerful and Advanced Google Colab Notebook for Zip, Unzip, Tar, UnTar, RaR, UnRaR Files in Google Drive

Dr.Caduceus 15 Aug 16, 2022
Analog clock that shows the weather instead of the actual numerical hour it points to.

Eli's weatherClock An digital analog clock but instead of showing the hours, the clock shows the weather at that hour of the day. So instead of showin

Kovin 154 Dec 01, 2022
Weee - Advanced project's versions bumper

Weee - Advanced project's versions bumper

Yan Kurbatov 2 Jun 06, 2022
A Python script that exports users from one Telegram group to another using one or more concurrent user bots.

ExportTelegramUsers A Python script that exports users from one Telegram group to another using one or more concurrent user bots. Make sure to set all

Fasil Minale 17 Jun 26, 2022
Polars-fun - Example notebooks for how to use pola.rs

polars-fun Polars is an awesome Rust DataFrame library with Python language bindings. This repo makes it easy to run Polars code on your local machine

Matthew Powers 2 Jun 28, 2022
Azure DevOps Extension for Azure CLI

Azure DevOps Extension for Azure CLI The Azure DevOps Extension for Azure CLI adds Pipelines, Boards, Repos, Artifacts and DevOps commands to the Azur

1 Nov 03, 2021