Skip to main content

Dispy - package for creating bots

Project description

Dispy

logo

version project language python version linting pylint mark documentation Status

Advantages

  • Package for async/await support
  • Registering events with wrappers
  • Easy code with syntax sugar

Needs minimal 3.8 python version

Dispy is package for creating bots in Discord. This package use discord API and discord Gateway for handle events or, for example, sending messages. Bot use for different goals; handle information on your server, creating mini games in discord, auto moderation in your discord server and other. For example, you can send messages use this code:

import disspy  # Import package

bot = disspy.DisBot(token="YOUR_TOKEN", application_id=00000)  # Create a bot

async def test():  # Send messages needs to execute in the async function
    channel_id = 000000  # Yours channel id
    channel = bot.get_channel(channel_id)  # Get the channel for sending to this channel a message
    
    await channel.send(content="Message!")  # Sending a message
    
if __name__ == '__main__':  # If file is started as a main file
    from asyncio import run  # Import asyncio.run
    
    run(test())  # Run async function

Download package

Download stable version

# Windows
pip install --upgrade disspy

# MacOS
py3 -m pip install --upgrade disspy

# Linux
sudo pip install --upgrade disspy

Download dev version

git clone https://github.com/itttgg/dispy.git
cd dispy
pip install --upgrade .

Links

https://github.com/itttgg/dispy - GitHub repo

https://pypi.org/project/disspy - Project site on PyPi

https://dispy-api-docs.readthedocs.io/en/latest - Site with docs for package

Using

Creating and running bot

import disspy

bot = disspy.DisBot(token="YOUR_TOKEN")

bot.run()

bot.on("ready")

import disspy

bot = disspy.DisBot(token="YOUR_TOKEN")


@bot.on("ready")
async def on_ready():
    print("Ready!")


bot.run()

bot.on("messagec")

message create event

import disspy

bot = disspy.DisBot(token="YOUR_TOKEN", flags=disspy.DisFlags.messages())


@bot.on("messagec")
async def on_messagec(message: disspy.DisMessage):
    await message.channel.send("Content: " + message.content)


bot.run()

bot.on("messageu")

message update event

import disspy

bot = disspy.DisBot(token="YOUR_TOKEN", flags=disspy.DisFlags.messages())


@bot.on("messageu")
async def on_messageu(message: disspy.DisMessage):
    await message.channel.send("New content of message: " + message.content)


bot.run()

bot.on("messaged")

message delete event

import disspy

bot = disspy.DisBot(token="YOUR_TOKEN", flags=disspy.DisFlags.messages())


@bot.on("messaged")
async def on_messaged(e: disspy.MessageDeleteEvent):
    await e.channel.send("You deleted message!")


bot.run()

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

disspy-0.5.4.tar.gz (30.6 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page