An API wrapper around Discord API written in Python

Overview

Diskord


This library is a maintained fork of now archived library, discord.py.

A modern and easy to use API wrapper around Discord API written in Python.

Features

  • Modern, Pythonic API based on async / await
  • Consistent, object oriented & easy to use interface
  • Provides full coverage of Discord API
  • Proper and sane ratelimit handling
  • Optimized in both speed and memory
  • Extensions support & prebuilt powerful commands handler

Installation

Python 3.8 or higher is required to install this library.

Basic Installation

To install the library without full voice support, you can just run the following command:

python -m pip install diskord

Voice Support

Optionally, To interact with discord's voice API, You would require voice support of this library which you can install like so:

python -m pip install diskord[voice]

Development Version

You must have git installed to install development version. Otherwise, you can download the code.

$ git clone https://github.com/nerdguyahmad/diskord
$ cd diskord
$ python -m pip install -U .[voice]

or in short;

python -m pip install git+https://github.com/diskord-dev/diskord.git

Quick Example

Here are some quick examples to give you a quickstart and show off the basic features of the library.

Application (Slash) Commands

import diskord

client = diskord.Client()

@client.slash_command(description='Ping-Pong!')
async def ping(ctx):
    await ctx.respond('Pong!')

client.run('token')

Legacy (Prefixed) Commands

import diskord
from diskord.ext import commands

bot = commands.Bot(command_prefix='>')

@bot.command()
async def ping(ctx):
    await ctx.send('pong')

bot.run('token')

You can find more examples in the examples directory.

Links

Comments
  • Bump aiohttp to a later version

    Bump aiohttp to a later version

    Summary

    Bump aiohttp to a later version

    Checklist

    • [ ] If code changes were made then they have been tested.
      • [ ] I have updated the documentation to reflect the changes.
    • [ ] This PR fixes an issue.
    • [ ] This PR adds something new (e.g. new method or parameters).
    • [ ] This PR is a breaking change (e.g. methods or parameters removed/renamed)
    • [x] This PR is not a code change (e.g. documentation, README, ...)

    Confirmations

    • [x] I have checked the open PRs and no PR exists like this one.
    • [x] My PR focuses on only one issue/change.
    needs testing 
    opened by Hype3808 7
  • Added 2 missing permissions

    Added 2 missing permissions

    https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags

    Summary

    Add START_EMBEDDED_ACTIVITIES and MODERATE_MEMBERS permissions.

    Can be found on https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags

    Checklist

    • [x] If code changes were made then they have been tested.
      • [x] I have updated the documentation to reflect the changes.
    • [ ] This PR fixes an issue.
    • [x] This PR adds something new (e.g. new method or parameters).
    • [ ] This PR is a breaking change (e.g. methods or parameters removed/renamed)
    • [ ] This PR is not a code change (e.g. documentation, README, ...)

    Confirmations

    • [x] I have checked the open PRs and no PR exists like this one.
    • [x] My PR focuses on only one issue/change.
    feature request 
    opened by Hype3808 4
  • SlashCommands object is not callable

    SlashCommands object is not callable

    Summary

    Just an error in pycharm with the lib

    Reproduction Steps

    import diskord
    from diskord.ext import commands
    bot = commands.Bot(command_prefix='!', application_command_guild_ids=834489585118740530)
    
    
    @bot.event
    async def on_ready():
        print('ready')
    
    
    @bot.slash_command()
    @diskord.application.option('text', description='The text to say!')
    async def say(ctx, text):
        await ctx.respond(f'{ctx.author.name} said: {text}')
    
    bot.run("")
    
    

    Using this code in PyCharm (from example but same result with my own code)

    Minimal Reproducible Code

    No response

    Expected Results

    0 error

    Actual Results

    Actually, i'm having this error "Object is not callable" for the SlashCommands object but when i run the code eveything is fine it's juste annoying that having 34 error but it's only like "fake error"

    Intents

    32767

    System Information

    • Python v3.9.7-final
    • diskord v2.6.1-final
    • aiohttp v3.7.4.post0
    • system info: Windows 10 10.0.22494

    Checklist

    • [X] I have searched the open issues for duplicates.
    • [X] I have shown the entire traceback, if possible.
    • [X] I have removed my token from display, if visible.

    Additional Context

    No response

    bug documentation typing 
    opened by dylanc24 4
  • Add Member.timeout

    Add Member.timeout

    Summary

    Added Member.timeout for ease of use

    Checklist

    • [ ] If code changes were made then they have been tested.
      • [x] I have updated the documentation to reflect the changes.
    • [ ] This PR fixes an issue.
    • [x] This PR adds something new (e.g. new method or parameters).
    • [ ] This PR is a breaking change (e.g. methods or parameters removed/renamed)
    • [ ] This PR is not a code change (e.g. documentation, README, ...)

    Confirmations

    • [x] I have checked the open PRs and no PR exists like this one.
    • [x] My PR focuses on only one issue/change.
    opened by MarzaElise 3
  • Make application commands register on `login`

    Make application commands register on `login`

    Summary

    Make application commands register on login instead of on_connect event so you don't have to manually register the slash commands when u call a on_connect.

    Checklist

    • [x] If code changes were made then they have been tested.
      • [ ] I have updated the documentation to reflect the changes.
    • [x] This PR fixes an issue.
    • [ ] This PR adds something new (e.g. new method or parameters).
    • [ ] This PR is a breaking change (e.g. methods or parameters removed/renamed)
    • [ ] This PR is not a code change (e.g. documentation, README, ...)

    Extra Checklist

    • [x] No errors have been raised when starting the bot

    Confirmations

    • [x] I have checked the open PRs and no PR exists like this one.
    • [x] My PR focuses on only one issue/change.
    opened by Hype3808 3
  • Implement thread starter message

    Implement thread starter message

    Summary

    So I added a method to diskord.Thread that fetches the message that the thread was created from. The method is called fetch_starter_message and it will return a diskord.Message. If the thread was created from a message, the message type will be default, otherwise it will be thread_starter_message. I also added a property called starter_message that will return the thread starter_message from the cache (can be None). The cache is updated everytime fetch_starter_message is called. This property can be useful when you don't want to make another API call after you already did.

    Checklist

    • [x] If code changes were made then they have been tested.
      • [x] I have updated the documentation to reflect the changes.
    • [ ] This PR fixes an issue.
    • [x] This PR adds something new (e.g. new method or parameters).
    • [ ] This PR is a breaking change (e.g. methods or parameters removed/renamed)
    • [x] This PR is not a code change (e.g. documentation, README, ...)
    feature request 
    opened by FlamptX 2
  • Help command with dropdown

    Help command with dropdown

    This is a help command made with the dropdown menu. The message will be always one (the bot will edit the same message and, of course, the dropdown menu will be always there) so there's no spam on the channel.

    opened by Tommodev-06 2
  • 2.5.1 -- Slash Extensions & Refactor : Refactor application commands to have instance attributes instead of properties

    2.5.1 -- Slash Extensions & Refactor : Refactor application commands to have instance attributes instead of properties

    1. Changed private callback properties into public attributes in ApplicationCommand class and SlashCommandChild class.
    2. A few very small PEP 8 fixes that I couldn't resist to leave like that :)

    From the 2.5.1 todo list, card link; https://github.com/diskord-dev/diskord/projects/2#card-69995521

    good first issue application commands hacktoberfest-accepted 
    opened by FlamptX 2
  • Add diskord to CC notice

    Add diskord to CC notice

    Summary

    Add diskord to CC notice

    Checklist

    • [ ] If code changes were made then they have been tested.
      • [ ] I have updated the documentation to reflect the changes.
    • [ ] This PR fixes an issue.
    • [ ] This PR adds something new (e.g. new method or parameters).
    • [ ] This PR is a breaking change (e.g. methods or parameters removed/renamed)
    • [x] This PR is not a code change (e.g. documentation, README, ...)

    Confirmations

    • [x] I have checked the open PRs and no PR exists like this one.
    • [x] My PR focuses on only one issue/change.
    opened by Hype3808 1
  • [documentation] Change favicon for docs

    [documentation] Change favicon for docs

    Summary

    Change favicon for docs

    Checklist

    • [ ] If code changes were made then they have been tested.
      • [ ] I have updated the documentation to reflect the changes.
    • [ ] This PR fixes an issue.
    • [ ] This PR adds something new (e.g. new method or parameters).
    • [ ] This PR is a breaking change (e.g. methods or parameters removed/renamed)
    • [x] This PR is not a code change (e.g. documentation, README, ...)

    Confirmations

    • [x] I have checked the open PRs and no PR exists like this one.
    • [x] My PR focuses on only one issue/change.
    opened by Hype3808 1
  • Create timeout.py

    Create timeout.py

    Summary

    This PR adds an example for the timeout feature (using the master branch version as specified at the top of the file).

    Checklist

    • [ ] If code changes were made then they have been tested.
      • [ ] I have updated the documentation to reflect the changes.
    • [ ] This PR fixes an issue.
    • [ ] This PR adds something new (e.g. new method or parameters).
    • [ ] This PR is a breaking change (e.g. methods or parameters removed/renamed)
    • [ x ] This PR is not a code change (e.g. documentation, README, ...)

    Confirmations

    • [ x ] I have checked the open PRs and no PR exists like this one.
    • [ x ] My PR focuses on only one issue/change.
    opened by SpaceBar-Dev 1
  • Make slash command registration in `start`

    Make slash command registration in `start`

    Summary

    Make slash command registration in start

    I excidently deleted the fork so the previous one closed..

    Checklist

    • [x] If code changes were made then they have been tested.
      • [ ] I have updated the documentation to reflect the changes.
    • [x] This PR fixes an issue.
    • [ ] This PR adds something new (e.g. new method or parameters).
    • [ ] This PR is a breaking change (e.g. methods or parameters removed/renamed)
    • [ ] This PR is not a code change (e.g. documentation, README, ...)

    Confirmations

    • [x] I have checked the open PRs and no PR exists like this one.
    • [x] My PR focuses on only one issue/change.
    opened by Hype3808 0
  • Slash attachments

    Slash attachments

    Summary

    Add support for slash attachments

    Checklist

    • [x] If code changes were made then they have been tested.
      • [ ] I have updated the documentation to reflect the changes.
    • [ ] This PR fixes an issue.
    • [x] This PR adds something new (e.g. new method or parameters).
    • [ ] This PR is a breaking change (e.g. methods or parameters removed/renamed)
    • [ ] This PR is not a code change (e.g. documentation, README, ...)

    Confirmations

    • [x] I have checked the open PRs and no PR exists like this one.
    • [x] My PR focuses on only one issue/change.
    opened by Hype3808 0
  • Webhook.edit_message leads to internal exception

    Webhook.edit_message leads to internal exception

    Summary

    Webhook.edit_message throws "AttributeError: PartialWebhookState does not support 'get_reaction_emoji'"

    Reproduction Steps

    My bot updates an embed on a regular cadence, so I store webhook urls in my database, then iterate through them. When posting the new embed, on some servers, I was seeing this in my logs.

    I tried with or without "webhook = await webhook.fetch()" to get the "full webhook" and still ran into the same exception. Seems like something on some servers is causing a path to look for reaction emoji.

    Minimal Reproducible Code

    async with aiohttp.ClientSession() as session:
                try:
                    webhook = diskord.Webhook.from_url(config.webhook, session=session)
                    webhook = await webhook.fetch()
                except diskord.InvalidArgument:
                    self.logging.error("Error: Webhook invalid. Disabling ID: {}".format(config.pk))
                    config.status = "Disabled"
                    config.save()
                    return
    
                try:
                    await webhook.edit_message(config.message_id, content="", embed=append_advert_if_needed(self.bot, config.server.pk, new_embed, lang=config.locale))
    
                except AttributeError as error:
                    #This is an error in the library
                    pass
    

    Expected Results

    No exception

    Actual Results

    Following exception was thrown.

    File "mycode/loopsv2.py", line 115, in update_message await webhook.edit_message(config.message_id, content="", embed=append_advert_if_needed(self.bot, config.server.pk, new_embed, lang=config.locale)) File "/lib/python3.9/site-packages/diskord/webhook/async_.py", line 1732, in edit_message message = self.create_message(data) File "/lib/python3.9/site-packages/diskord/webhook/async.py", line 1363, in _create_message return WebhookMessage(data=data, state=state, channel=channel) # type: ignore File "/lib/python3.9/site-packages/diskord/message.py", line 712, in init self.reactions: List[Reaction] = [ File "/lib/python3.9/site-packages/diskord/message.py", line 713, in Reaction(message=self, data=d) for d in data.get("reactions", []) File "/lib/python3.9/site-packages/diskord/reaction.py", line 90, in init ] = emoji or message.state.get_reaction_emoji(data["emoji"]) File "/lib/python3.9/site-packages/diskord/webhook/async.py", line 718, in getattr raise AttributeError(f"PartialWebhookState does not support {attr!r}.") AttributeError: PartialWebhookState does not support 'get_reaction_emoji'.

    Intents

    None

    System Information

    • Python v3.9.9-final
    • diskord v2.6.1-final
    • aiohttp v3.7.4.post0
    • system info: Linux 5.13.19-2-pve #1 SMP PVE 5.13.19-4 (Mon, 29 Nov 2021 12:10:09 +0100)

    Checklist

    • [X] I have searched the open issues for duplicates.
    • [X] I have shown the entire traceback, if possible.
    • [X] I have removed my token from display, if visible.

    Additional Context

    No response

    unconfirmed bug 
    opened by aldalen 0
  • Multiprocess Sharding(`IPC`) Module

    Multiprocess Sharding(`IPC`) Module

    Summary

    The creation of a ext.ipc module based off the Ext-Creators one

    What is the feature request for?

    The core library

    The Problem

    Having to host both the bot and server on the same server

    The Ideal Solution

    Creating the ipc.Session and ipc.Server processes for creating Sessions which interact with the Server separately

    from diskord.ext import ipc, commands
    
    session = ipc.Server(...)
    
    bot = commands.Bot(...)
    
    @session.route(...)
    async def get_member_count(data):
        guild = bot.get_guild(data.guild_id)
    
        return guild.member_count
    
    

    and a Server process in a different server

    from sanic import Sanic
    from diskord.ext import ipc
    
    server = Sanic(__name__)
    session = ipc.Session(...)
    
    @server.route("/")
    async def index():
        req_str = await session.request(...)
    
        return str(req_str)
    

    The stuff above are mostly based off the discord-ext-ipc examples.

    The Current Solution

    No response

    Additional Context

    No response

    feature request 
    opened by VincentRPS 0
  • Support for cooldowns within Application Commands

    Support for cooldowns within Application Commands

    Summary

    Being able to use cooldowns and max concurrency on slash commands

    What is the feature request for?

    The core library

    The Problem

    having users execute commands too fast or use commands such as economy without proper cooldowns

    The Ideal Solution

    just adding them mostly based of current cooldowns and max concurrency

    The Current Solution

    No response

    Additional Context

    No response

    feature request 
    opened by VincentRPS 0
  • Converters raising attribute error.

    Converters raising attribute error.

    Summary

    commands.Greedy not working

    Reproduction Steps

    import diskord
    from diskord.ext import commands
    
    class Test(commands.Cog):
    	def __init__(self, client):
    		self.client = client
    	
    	
    	@diskord.application.slash_command()
    	@diskord.application.option("channels", required = True)
    	async def test(self, ctx, *, channels : commands.Greedy[diskord.TextChannel]):
    		pass
    		
    
    
    
    def setup(client):
    	client.add_cog(Test(client))
    

    Minimal Reproducible Code

    No response

    Expected Results

    No error

    Actual Results

    Gives the error: AttributeError: 'Greedy' object has no attribute '__name__'

    Full error: https://pastebin.com/pBRwzjkm

    Intents

    None

    System Information

    • Python v3.9.7-final
    • diskord v2.6.1-final
    • aiohttp v3.7.4.post0
    • system info: Linux 4.9.82-perf+ #2 SMP PREEMPT Sat Mar 6 01:27:24 CST 2021

    Checklist

    • [X] I have searched the open issues for duplicates.
    • [X] I have shown the entire traceback, if possible.
    • [x] I have removed my token from display, if visible.

    Additional Context

    No response

    bug application commands 
    opened by RyZeDZ 1
Releases(v2.6.2)
  • v2.6.2(Nov 6, 2021)

    Breaking Changes

    • Autocomplete callbacks now take Option as a second parameter before interaction and after value.
    • Removed ignore_guild_register_fail from commands registration methods.
    • Guild IDs related to application commands now default to None instead of empty list.
      • Client.application_commands_guild_ids now default to None.
      • ApplicationCommand.guild_ids now default to None.
    • Redesigned application commands registration.
      • Guild commands are bulk overwritten on every call.
      • Global commands are not re-registered if they are not updated.
      • sync_application_commands now bulk overwrites guild commands. Use Client.create_application_command instead.

    Additions

    • Add support for bypassing registration process by adding id parameter in application command.
    • Add support for guild boosts progress bar.
    • Add diskord.Client.create_application_command

    Bug Fixes

    • Fix reference error on guild command registration fail.
    • Duplicate guild IDs in application commands are now properly ignored.
    • Fix type kwarg being ignored by diskord.application.option decorator.
    • Other minor fixes.

    Documentation also has been fixed and now has proper hyperlinks on attributes.

    Source code(tar.gz)
    Source code(zip)
  • v2.6.1(Oct 23, 2021)

    • Add support minimum and maximum values on slash commands options
      • Add application.Option.min_value
      • Add application.Option.max_value
    • Rename Client.application_commands_guild_ids to Client.application_command_guild_ids
    • Client.application_commands is now a list instead of ID to command mapping.
    • Fix NameError on guilds commands registration failing to register
    • Fix application.ApplicationCommand.default_permissions not working at all.
    • Fix repr(ApplicationCommand) raising AttributeError
    • Fix getters and fetchers from Guild for commands not working at all.
    Source code(tar.gz)
    Source code(zip)
  • 2.6.0(Oct 18, 2021)

    Breaking Changes

    • Rename diskord.slash_option decorator to diskord.application.option
    • Move user constructable application commands classes to application namespace.
    • Rename on_application_command_run to on_application_command
    • Application Commands are now handled internally like components. Client.process_application_commands has been removed.
    • Application commands permissions rework. See the relevant documentation for more details.

    Additions

    • Implement autocompletion for slash commands options (#15)
    • Implement support for sending files in diskord.InteractionResponse.send_message
    • Add diskord.application.ApplicationCommand.extras to diskord.application.ApplicationCommand (#11)
    • Add application_commands_guild_ids parameter to diskord.Client to prevent bot from creating global commands.
    • Add diskord.ApplicationCommand.edit and diskord.ApplicationCommand.delete methods.
    • Rename diskord.Client.get_application_context to diskord.Client.get_interaction_context

    Improvements

    • diskord.application.ApplicationCommand.callback is now settable.
    • Converters can now be determined by the option annotations in slash commands.

    Bug Fixes

    • Fix role icons not being set properly.
    • Fix previous options for application commands getting re-added after command has been removed and added back to pending commands list.
    • Fix user option resolving to None in slash commands if member intents are missing.
    • Fix files raising AttributeError
    Source code(tar.gz)
    Source code(zip)
  • v2.5.1(Oct 3, 2021)

  • v2.5.0(Oct 2, 2021)

    • Support for Application Commands :tada:
    • Partial Support for Application Commands extensions.
    • Support for role icons
    • Support guild welcome screen
    • Add raw_thread_delete event
    • Add raw_typing events

    https://diskord.readthedocs.io/en/latest/migrating.html https://diskord.readthedocs.io/en/latest/application_commands.html

    Source code(tar.gz)
    Source code(zip)
Owner
Diskord
An API wrapper around Discord API, Originated as a fork of discord.py
Diskord
An API wrapper around Discord API.

NeoCord This project is work in progress not for production use. An asynchronous API wrapper around Discord API written in Python. Features Modern API

Izhar Ahmad 14 Jan 3, 2022
Discord-Wrapper - Discord Websocket Wrapper in python

This does not currently work and is in development Discord Websocket Wrapper in

null 3 Oct 25, 2022
Python API wrapper around Trello's API

A wrapper around the Trello API written in Python. Each Trello object is represented by a corresponding Python object. The attributes of these objects

Richard Kolkovich 904 Jan 2, 2023
An API wrapper around the pythonanywhere's API.

pyaww An API wrapper around the pythonanywhere's API. The name stands for pythonanywherewrapper. 100% api coverage most of the codebase is documented

null 7 Dec 11, 2022
An API wrapper around the pythonanywhere's API.

pyaww An API wrapper around the pythonanywhere's API. The name stands for pythonanywherewrapper. 100% API coverage Most of the codebase is documented

null 7 Dec 11, 2022
A Anything goes Discord bot written in python and uses the wrapper Discord.py

GerardTheWizard A Anything goes Discord bot written in python and uses the wrapper Discord.py What can he do? Allow users to level up through typing,

null 1 May 5, 2022
A Python wrapper around the OpenWeatherMap web API

PyOWM A Python wrapper around OpenWeatherMap web APIs What is it? PyOWM is a client Python wrapper library for OpenWeatherMap (OWM) web APIs. It allow

Claudio Sparpaglione 740 Dec 18, 2022
A Python wrapper around the Soundcloud API

soundcloud-python A friendly wrapper around the Soundcloud API. Installation To install soundcloud-python, simply: pip install soundcloud Or if you'r

SoundCloud 83 Dec 12, 2022
A Python wrapper around the Twitter API.

Python Twitter A Python wrapper around the Twitter API. By the Python-Twitter Developers Introduction This library provides a pure Python interface fo

Mike Taylor 3.4k Jan 1, 2023
A Python wrapper around the Twitter API.

Python Twitter A Python wrapper around the Twitter API. By the Python-Twitter Developers Introduction This library provides a pure Python interface fo

Mike Taylor 3.4k Jan 1, 2023
An async-ready Python wrapper around FerrisChat's API.

FerrisWheel An async-ready Python wrapper around FerrisChat's API. Installation Instructions Linux: $ python3.9 -m pip install -U ferriswheel Python 3

FerrisChat 8 Feb 8, 2022
A Python wrapper around the Pushbullet API to send different types of push notifications to your phone or/and computer.

pushbullet-python A Python wrapper around the Pushbullet API to send different types of push notifications to your phone or/and computer. Installation

Janu Lingeswaran 1 Jan 14, 2022
Linky bot, A open-source discord bot that allows you to add links to ur website, youtube url, etc for the people all around discord to see!

LinkyBot Linky bot, An open-source discord bot that allows you to add links to ur website, youtube url, etc for the people all around discord to see!

AlexyDaCoder 1 Sep 20, 2022
A light wrapper around FedEx's SOAP API.

Python FedEx SOAP API Module Author: Greg Taylor, Radek Wojcik Maintainer: Python FedEx Developers License: BSD Status: Stable What is it? A light wra

null 155 Dec 16, 2022
Wrapper around the Mega API

python-mega Overview Wrapper around the Mega API. Based on the work of Julien Marchand. Installation Install using pip, including any optional package

Juan Riaza 104 Nov 26, 2022
Wrapper around the latest Tuenti API

python-tuenti Overview Wrapper around the latest Tuenti API. Installation Install using pip, including any optional packages you want... $ pip install

Juan Riaza 10 Mar 7, 2022
Wrapper around the UPS API for creating shipping labels and fetching a package's tracking status.

ClassicUPS: A Useful UPS Library ClassicUPS is an Apache2 Licensed wrapper around the UPS API for creating shipping labels and fetching a package's tr

Jay Goel 55 Dec 12, 2022
A small and fun Discord Bot that is written in Python and discord-interactions (with discord.py)

Articuno (discord-interactions) A small and fun Discord Bot that is written in Python and discord-interactions (with discord.py) Get started If you wa

Blue 8 Dec 26, 2022
An API wrapper for Discord written in Python.

discord.py A modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python. Key Features Modern Pythonic API using asyn

Danny 12k Jan 8, 2023