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
discord token grabber scam - eductional purposes only!

Discord-QR-Scam תופס אסימון תמונה של Discord על אודות סקריפט Python שיוצר אוטומטית קוד QR הונאה של Nitro ותופס את אסימון הדיסקורד בעת סריקה. כלי זה מד

Amit Pinchasi 0 May 22, 2022
FTX auto lending bot with python

FTX auto lending bot Get the API key Check my article for step by step + screenshots Setup & Run Install python 3 Install dependency pip install -r re

Patompong Manprasatkul 1 Dec 24, 2021
This repository is used to provide data to zzhack,

This repository is used to provide data to zzhack, but you don't have to care about anything, just write your thinking down, and you can see your thinking is rendered in zzhack perfectly

5 Apr 29, 2022
Projeto com o objetivo de aprender o funcionamento de Consumo de APIs.

Consumindo API SuperHero Projeto com o objetivo de aprender o funcionamento de Consumo de APIs.

Deivisson Henrique 1 Dec 30, 2021
Widevine MPD Content Downloader & Decryptor

Widevine-DL Encrypted MPD Manifest Content Downloader + Decryptor (not a Widevine Key Extractor!) Requirements ffmpeg, yt-dlp, aria2, widevine-l3-decr

Vank0n (SJJeon) 170 Dec 30, 2022
Provide fine-grained push access to GitHub from a JupyterHub

github-app-user-auth Provide fine-grained push access to GitHub from a JupyterHub. Goals Allow users on a JupyterHub to grant push access to only spec

Yuvi Panda 20 Sep 13, 2022
Python lib for Embedly

embedly-python Python library for interacting with Embedly's API. To get started sign up for a key at embed.ly/signup. Install Install with Pip (recom

Embedly 80 Oct 05, 2022
Python Proof of Concept for retrieving Now Playing on YouTube Music with TabFS

Youtube Music TabFS Python Proof of Concept for retrieving Now Playing on YouTube Music with TabFS. music_information = get_now_playing() pprint(music

Junho Yeo 41 Nov 06, 2022
Telegram File Renamer Bot

RENAMER_BOT Telegram File Renamer Bot Configs TG_BOT_TOKEN - Get bot token from @BotFather API_ID - From my.telegram.org API_HASH - From my.telegram.o

Lntechnical 37 Dec 27, 2022
Images to PDF Telegram Bot

ilovepdf Convert Images to PDF Bot This bot will helps you to create pdf's from your images [without leaving telegram] 😉 By Default: your pdf fil

✰Naͥbiͣlͫ A Navab✰ 116 Dec 29, 2022
💬 Send iMessages using Python through the Shortcuts app.

py-imessage-shortcuts Send iMessages using Python through the Shortcuts app. Requires macOS Monterey (macOS 12) or later. Compatible with Apple Silico

Kevin Schaich 10 Nov 30, 2022
Compares and analyzes GCP IAM roles.

gcp-iam-analyzer I wrote this to help in my day to day working in GCP. A lot of the time I am doing role comparisons to see which role has more permis

Jason Dyke 37 Dec 28, 2022
Python wrapper for Interactive Brokers Client Portal Web API

EasyIB: Unofficial Wrapper for Interactive Brokers API EasyIB is an unofficial python wrapper for Interactive Brokers Client Portal Web API. Features

39 Dec 13, 2022
Aqui está disponível GRATUITAMENTE, um bot de discord feito em python, saiba que, terá que criar seu bot como aplicação, e utilizar seu próprio token, e lembrando, é um bot básico, não se utiliza Cogs nem slash commands nele!

BotDiscordPython Aqui está disponível GRATUITAMENTE, um bot de discord feito em python, saiba que, terá que criar seu bot como aplicação, e utilizar s

Matheus Muguet 4 Feb 05, 2022
Fetch the details of assets hosted on AWS.

onaws onaws is a simple tool to check if an IP/hostname belongs to the AWS IP space or not. It uses the AWS IP address ranges data published by AWS to

Amal Murali 80 Dec 29, 2022
Widevine CDM API

wvproxy Widevine CDM API Setup Install Python 3.6 or newer and Poetry Install Python package dependencies using poetry install Activate the virtual en

24 Dec 09, 2022
KaydyPurge - Python Purge Script for Discord made by Kaydy Cain#0001

How to Install Open terminal Execute "git clone https://github.com/apolo1337/Kay

apolo 5 Jan 27, 2022
This is a DCA crypto trading bot built for Binance written in Python

This is a DCA crypto trading bot built for Binance written in Python. It works by allowing you to DCA at an interval of your choosing and reports back on your average buy price as well as a chart con

Andrei 55 Oct 17, 2022
Python: Asynchronous client for the Tailscale API

Python: Asynchronous client for the Tailscale API Asynchronous client for the Tailscale API. About This package allows you to control and monitor Tail

Franck Nijhof 9 Nov 22, 2022
🔍 Google Search unofficial API for Python with no external dependencies

Python Google Search API Unofficial Google Search API for Python. It uses web scraping in the background and is compatible with both Python 2 and 3. W

Avi Aryan 204 Dec 28, 2022