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 module grouping multiple translation APIs

translatepy (originally: translate) An aggregation of multiple translation API Translate, transliterate, get the language of texts in no time with the

349 Jan 06, 2023
A bot written in python that send prefilled Google Forms. It supports multithreading for faster execution time.

GoogleFormsBot https://flassy.xyz https://github.com/Shawey/GoogleFormsBot Requirements: os (Default) ast (Default) threading (Default) configparser (

Shawey 1 Jul 10, 2022
Official python API for Phish.AI public and private API to detect zero-day phishing websites

phish-ai-api Summary Official python API for Phish.AI public and private API to detect zero-day phishing websites How it Works (TLDR) Essentially we h

Phish.AI 168 May 17, 2022
Automate saving your Discover Weekly Playlist using Python.

SpotWeekly Automate saving your Discover Weekly Playlist using Python. Made with 3 and FastAPI. The saved playlist link is sent to my discord server

shourya 6 Jan 03, 2022
Pinopoly is a tool to remove the "banker" player and replace them with a digitalized system

Pinopoly is a tool to remove the "banker" player and replace them with a digitalized system. It is intended to be used on a Raspberry Pi but can be used in the command line as well.

Alex Overstreet 11 Jul 09, 2022
Pogodasbot - Telegram bot sending channel weather info

Pogodasbot - Telegram bot sending channel weather info

Qayrat Sultan 1 Dec 15, 2022
Tinyman Python SDK

tinyman-py-sdk Tinyman Python SDK Design Goal This SDK is designed for automated interaction with the Tinyman AMM. It will be most useful for develope

Tinyman 113 Dec 30, 2022
Plataforma para atendimento a outras empresas que necessitam de atendimento técnico.

Plataforma para atendimento a outras empresas que necessitam de atendimento técnico. É possível que os usuarios de empresas parceiras registrem solici

Kelvin Alisson Cantarino 2 Jun 29, 2022
A heraldry-related bot, designed for the Heraldry Community.

Heraldtron A heraldry-related bot, designed for the Heraldry Community. Requirements Python 3.9+ discord.py aiohttp (comes installed with discord.py)

1 Mar 31, 2022
A curated list of awesome Amazon Web Services (AWS) libraries, open source repos, guides, blogs, and other resources.

A curated list of awesome Amazon Web Services (AWS) libraries, open source repos, guides, blogs, and other resources. Featuring the Fiery Meter of AWSome.

Donne Martin 11.1k Jan 04, 2023
Ghost-toolbox - Ghost's official Discord raid tool

Ghost Toolbox Ghost's official Discord raid tool. How to use Clone this repo int

G H Ø S T 10 Oct 31, 2022
Python library for the DeepL language translation API.

The DeepL API is a language translation API that allows other computer programs to send texts and documents to DeepL's servers and receive high-quality translations. This opens a whole universe of op

DeepL 535 Jan 04, 2023
AWS DeepRacer Free Student Workshop: Run faster by using your custom waypoints

AWS DeepRacer Free Student Workshop: Run faster by using your custom waypoints Reward Function Template for waypoints def reward_function(params):

Yuen Cheuk Lam 88 Nov 27, 2022
Zero2 Discord bot is written with Discord.py using Python.

Zero2 Discord bot is written with Discord.py using Python.

Siva Avanish 4 Nov 08, 2021
An open souce video/music streamer based on MPV and piped.

🎶 Harmony Music An easy way to stream videos or music from Youtube from the command line while regaining your privacy. 📖 Table Of Contents ❔ What's

Zingy Tomato 16 Nov 15, 2022
ESOLinuxAddonManager - Very simple addon manager for Elder Scrolls Online running on Linux.

ESOLinuxAddonManager Very simple addon manager for Elder Scrolls Online running on Linux. Well, more a downloader for now. Currently it's quite ugly b

Akseli 25 Aug 28, 2022
Twitter bot that turns comment chains into ace attorney scenes. Inspired by and using https://github.com/micah5/ace-attorney-reddit-bot

Ace Attorney twitter Bot Twitter bot that turns comment chains into ace attorney scenes. Inspired by and using https://github.com/micah5/ace-attorney-

Luis Mayo Valbuena 542 Dec 17, 2022
This repository provides a set functions to extract paragraphs from AWS Textract responses.

extract-paragraphs-with-aws-textract Since AWS Textract (the AWS OCR service) does not have a native function to extract paragraphs, this repository p

Juan Anzola 3 Jan 26, 2022
Userbot untuk memutar video dan lagu di vcg/os

Userbot untuk memutar video dan lagu di vcg/os

FJ_GAMING 2 Nov 13, 2021
PepeSniper is an open-source Discord Nitro auto claimer/redeemer made in python.

PepeSniper is an open-source Discord Nitro auto claimer made in python. It sure as hell is not the fastest sniper out there but it gets the job done in a timely and stable manner. It also supports ho

Unknown User 1 Dec 22, 2021