A helper module for discord.py
Project description
discord-helpers
A helper module for discord.py
Current Features (v0.0.5)
- Per server custom prefixes using SQLite3 - aiosqlite
- Invite tracker
- Paginator
- Chatbot coroutine to get a reply from an AI (The Random Stuff API)
- A cycling status for your bot
- A function to create a rich embed with every feature in a simple line of code
- A coroutine to find a webhook from a channel and send a message via it
- Coroutines for using the GET and POST methods easily
Installation
Stable Release:
pip install -U discord-helpers
Development:
pip install -U git+https://github.com/Dorukyum/discord-helpers.git
Some Examples
Prefixes
import discord
from discord.ext import commands, helpers
bot = commands.Bot(command_prefix = "!", intents = discord.Intents.all())
@bot.event
async def on_ready():
bot.db = helpers.Database(bot, "data.db") # also used in the examples below
bot.command_prefix = bot.db.custom_prefix("!")
@bot.event
async def on_message(message):
if message.mentions[0] == client.user:
await bot.db.reply_with_prefix(message)
@bot.command()
async def change_prefix(ctx, *, prefix):
await bot.db.change_prefix(ctx.guild.id, prefix)
Chatbot
@bot.event
async def on_message(message):
if message.channel.id == my_chatbot_channel_id:
response = await helpers.chatbot(message.content, api_key=my_api_key)
await message.reply(response)
Paginator
@bot.command()
async def send_pages(ctx):
paginator = helpers.Paginator(bot, pages=(discord.Embed(title="Page 1"),))
paginator.add_page(discord.Embed(title="Page 2"))
await paginator.start(ctx)
Invite Tracker
@bot.event
async def on_invite_create(inv):
await bot.db.invite_tracker.add_invite(inv)
# and so on for the guild_join, guild_remove and invite_delete events
@bot.event
async def on_member_join(member):
inviter, invite = await bot.db.invite_tracker.track(member)
await bot.get_channel(my_channel_id).send(inviter.name)
await bot.db.invite_tracker.increment_uses(invite, 1)
Webhooks
@bot.command()
async def send_webhook(ctx, *, text):
await helpers.Webhooks.find_and_send(text, channel=ctx.channel, webhook_name="Test")
Status
bot.status = helpers.StatusCycle("status 1", "status 2")
@tasks.loop(minutes=3)
async def change_status():
await bot.change_presence(activity=discord.Game(bot.status.next()))
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
discord-helpers-0.0.5.tar.gz
(7.9 kB
view hashes)
Built Distribution
Close
Hashes for discord_helpers-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | addde98a3c5851a68ad418f6c7f3c65dba04d5c5b7c706b001870319e14e2c5d |
|
MD5 | eb3ad4aca392b78badee22f4ed247401 |
|
BLAKE2b-256 | de07effca81a3032e395930cc0c1f21c04904a753177a449b5c514fa1ffa4412 |