In this tutorial I will go through the entire length of pagination in discord.py
I kindly ask you to go through the entire thing, as it is not recommended to skip the subtopics because they are interconnected in some way.
import redis from '@/lib/redis' | |
import { tap } from '@/lib/utils' | |
import { NextResponse } from 'next/server' | |
import { NowPlaying } from '@/types/activities' | |
import { base64_encode, use } from '@/lib/utils' | |
type SpotifyResponse = { | |
is_playing: boolean | |
progress_ms: number | |
item: { |
In this tutorial I will go through the entire length of pagination in discord.py
I kindly ask you to go through the entire thing, as it is not recommended to skip the subtopics because they are interconnected in some way.
Motor is an async Python driver for MongoDB.
You should use Motor when you're trying to interact with a MongoDB database in an asynchronous context. When you're making something that needs to be asynchronous (like a web server, or most commonly from what I've seen here, Discord bots), you also want all the database calls to be done asynchronously. But pymongo is synchronous, i.e it is blocking, and will block the execution of your asynchronous program for the time that it is talking to the database.
Thankfully for us, switching from pymongo to Motor isn't too hard, and won't need you to change much code. This process can be roughly summarized as:
Installing can be done with pip - pip install motor
This guide will walkthrough the ways to create a custom help command by subclassing HelpCommand.
<? | |
# MIT license, do whatever you want with it | |
# | |
# This is my invoice.php page which I use to make invoices that customers want, | |
# with their address on it and which are easily printable. I love Stripe but | |
# their invoices and receipts were too wild for my customers on Remote OK | |
# | |
require_once(__DIR__.'/../vendor/autoload.php'); |
import discord | |
from discord.ext import commands | |
from discord.errors import Forbidden | |
"""This custom help command is a perfect replacement for the default one on any Discord Bot written in Discord.py! | |
However, you must put "bot.remove_command('help')" in your bot, and the command must be in a cog for it to work. | |
Original concept by Jared Newsom (AKA Jared M.F.) | |
[Deleted] https://gist.github.com/StudioMFTechnologies/ad41bfd32b2379ccffe90b0e34128b8b | |
Rewritten and optimized by github.com/nonchris |
player
is better than plr
.wasCalled
is better than hasBeenCalled
. notify
is better than doNotification
.isFirstRun
is better than firstRun
.increment
is better than plusOne
. unzip
is better than filesFromZip
.onClick
is better than click
.isFlying
instead of isNotFlying
. late
intead of notOnTime
.if not something then ... else ... end
.missingValue
instead of not hasValue
.Here is an updated list of the colors that are currently implemented with a name.
To using colors on discord.js, this is a typedef Colors, Colors.Aqua
to get the Aqua color.
Name | Int value | Hex Code |
---|---|---|
Default |
0 | #000000 |
Aqua |
1752220 | #1ABC9C |
DarkAqua |
1146986 | #11806A |
Green |
5763719 | #57F287 |
DarkGreen |
2067276 | #1F8B4C |
""" | |
If you are not using this inside a cog, add the event decorator e.g: | |
@bot.event | |
async def on_command_error(ctx, error) | |
For examples of cogs see: | |
https://gist.github.com/EvieePy/d78c061a4798ae81be9825468fe146be | |
For a list of exceptions: | |
https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#exceptions |