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 simple Telegram bot that can broadcast messages and media to the bot subscribers. with mongo DB support

𝘽𝙧𝙤𝙖𝙙𝙘𝙖𝙨𝙩 𝘽𝙤𝙩 A simple Telegram bot that can broadcast messages and media to the bot subscribers using MongoDB. Features Support mongodb.c

N A C BOTS 70 Jan 02, 2023
Send to Telegram, Vk, Discord

Triple send Версия для русских: здесь Demo: Telegram: @Triple_project_bot Discord: Triple project#0877 Vkontakte: @dev.santaspeen How to run Install r

2 Sep 27, 2022
A Telegram bot for Minecraft names

MCTelegramBot About this project This bot allows you to see data about minecraft names in Telegram, it has a few commands such as: /names - Show dropp

Kami 5 May 14, 2022
A wordwolf bot with python

ワードウルフBot requirements.txtから依存ライブラリをインストールしてください discordのトークン/Google spread sheetのキー/Sheetの名前を.envに書き込んでください DISCORD_TOKEN SHEET_KEY SHEET_NAME また、.sh

Kato 2 Dec 11, 2022
Discord bot written in discord.py

Orion Discord bot written in discord.py Installation Installation of code is supported for macOS only currently First open the terminal. If incase you

Zeus 3 May 19, 2022
The Bot provide Hadith API and fetch content via api.hadith.sutanlab.id

Bot Hadith-API on Telegram The Bot provide Hadith API and fetch content via api.hadith.sutanlab.id Built With Python Asynchronous HTTP protocol client

xMan 12 Feb 19, 2022
This is a simple collection of instructions and scripts to accompany the computerphile video about mininet and openflow.

How to get going. This project should work on Linux or MacOS. I used Ubuntu 20.04 and provide some notes here. Note, this is certainly not intended as

Richard G. Clegg 70 Jan 02, 2023
A Python Library to interface with Tumblr v2 REST API & OAuth

Tumblpy Tumblpy is a Python library to help interface with Tumblr v2 REST API & OAuth Features Retrieve user information and blog information Common T

Mike Helmick 125 Jun 20, 2022
A telegram bot to interact with a Minecraft Server

telegram-mc-bot A telegram bot to interact with a Minecraft Server It has the following commands: /status - Returns the server status (Online/Offline)

KleynArt 1 Dec 09, 2021
Video Stream: an Advanced Telegram Bot that's allow you to play Video & Music on Telegram Group Video Chat

Video Stream is an Advanced Telegram Bot that's allow you to play Video & Music

SHU KURENAI TEAM 4 Nov 05, 2022
Library to manage your own custom RPC on your desktop

Info I don't recommend novices setting this up yourself. It requires Redis, a server to host the API on, and a bit of understanding of Windows & Pytho

Isaac K 1 Apr 16, 2022
The community bot for the Python Discord community

Python Utility Bot This project is a Discord bot specifically for use with the Python Discord server. It provides numerous utilities and other tools t

Python Discord 998 Jan 03, 2023
Assistant made in python to control your spotify via voice

Spotify-Assistant Assistant made in python to control your spotify via voice Overview 🚀 PLAY, PAUSE, NEXT, PREVIOUS, VOLUME COMMANDS 📝 Toast notific

Mauri 6 Jan 18, 2022
Implement backup and recovery with AWS Backup across your AWS Organizations using a CI/CD pipeline (AWS CodePipeline).

Backup and Recovery with AWS Backup This repository provides you with a management and deployment solution for implementing Backup and Recovery with A

AWS Samples 8 Nov 22, 2022
Previewer for VapourSynth scripts.

Standalone previewer for VapourSynth scripts Fork of Endilll's vapoursynth-preview (not maintained anymore) This program is meant to be paired with a

Irrational Encoding Wizardry 26 Dec 16, 2022
A web app via which users can buy and sell stocks using virtual money

finance Virtual Stock Trader. A web app via which users can buy and sell stocks using virtual money. All stock prices are real and provided by IEX. Fe

Kiron Deb 0 Jan 15, 2022
un outil pour bypasser les code d'états HTTP négatif coté client ( 4xx )

4xxBypasser un outil pour bypasser les code d'états HTTP négatif coté client ( 4xx ) Liscence : MIT license Creator Installation : git clone https://g

21 Dec 25, 2022
Guilherme Matheus 11 Sep 11, 2022
Instrument asyncio Python for distributed tracing with AWS X-Ray.

xraysink (aka xray-asyncio) Extra AWS X-Ray instrumentation to use distributed tracing with asyncio Python libraries that are not (yet) supported by t

Gary Donovan 12 Nov 10, 2022
A telegram bot does not allow channels to send messages to the telegram supergroup

Channel Message Handler Getting started Installation $ git clone https://github.com/AbhijithNT/GroupChannelHandler.git Change directory $ cd ChannelMe

Abhijith N T 0 Dec 26, 2021