IzunaDevs / discord.webhooks

Webhooks extension to discord.py

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

discord.webhooks

This is an extension to discord.py that allows you to use webhooks for discord bots.

This does depend on discord.py being installed however it is not installed when installing this package.

All dependencies should be installed already.

The reason why I do not do this is when someone needs to keep the voice support of discord.py installed.

To install on Windows

path\to\python.exe -m pip install --upgrade discord.webhooks

To install on Linux

pip3 install --upgrade discord.webhooks

Requirements

  • discord.py
  • Python 3.4+

Documentation

See docs/usage.rst for documentation.

Example

example cog using the commands extension in discord.py that uses discord.webhooks:

from discord.ext import commands
from discord_webhooks import *

class WebhookExample:
    """webhook example cog class that contains an webhook example command."""
    def __init__(self, bot):
        self.webhook_class = Webhook(bot)
        self.request_webhook = self.webhook_class.request_webhook  # to request an webhook.

    @commands.command(name='examplecommand', pass_context=True, no_pm=True)
    async def examplecommand_command(self, ctx):
        """
        sends whatever you typed into the command after the bot prefix + 'examplecommand' via webhook.
        """
        msgdata = ctx.message.content[len(ctx.prefix + "examplecommand"):].strip()
        await self.request_webhook('/{channel id}/{webhook token}', content=msgdata)


def setup(bot):
    """
    example webhook cog.
    """
    new_cog = WebHooks(bot)
    bot.add_cog(new_cog)

About

Webhooks extension to discord.py

License:MIT License


Languages

Language:Python 95.1%Language:Batchfile 3.7%Language:Shell 1.3%