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
It's a discord.py simulator.

DiscordPySimulator It's a discord.py simulator. ⚠️ Things to fix Context As you may know, discord py commands provide the context as the first paramet

Juan Sebastián 11 Oct 24, 2022
Telegram bot for downloading covid-19 vaccine certificate

cowin-certificate-bot This is the source code of @cowincertbot, A telegram bot inspired by the whatsapp bot implementation of indian government for co

ArUn Pt 30 Oct 07, 2022
Python Client for Instagram API

This project is not actively maintained. Proceed at your own risk! python-instagram A Python 2/3 client for the Instagram REST and Search APIs Install

Facebook Archive 2.9k Dec 30, 2022
This is an Advanced Calculator maybe with Discord Buttons in python.

Welcome! This is an Advanced Calculator maybe with Discord Buttons in python. This was the first version of the calculator, made for my discord bot, P

Polsulpicien 18 Dec 24, 2022
Simple yet efficient tool used to check and sort tokens in terms of there validation.

Discord Token Checker Simple yet efficient tool used to check and sort tokens in terms of there validation.When the program is done,go to the "output"

Robotnik 15 Dec 27, 2022
A Open source Discord Token Grabber with several very useful features coded in python 3.9

Kiwee-Grabber A Open source Discord Token Grabber with several very useful features coded in python 3.9 This only works on any python 3.9 versions. re

Vesper 40 Jan 01, 2023
A discord.py bot template with Cogs implemented.

discord-cogs-template A discord.py bot template with Cogs implemented. Instructions Before you start ⚠ Basic knowledge of python is required. Steps If

censor 2 Sep 02, 2022
Wrapper for wttr.in weather forecast.

pywttr Wrapper for wttr.in weather forecast. Asynchronous version here. Installation pip install pywttr Example This example prints the average temper

Almaz 6 Dec 25, 2022
A small script to migrate or synchronize users & groups from Okta to AWS SSO

aws-sso-sync-okta A small script to migrate or synchronize users & groups from Okta to AWS SSO Changelog Version Remove hardcoded values on variables

Paul 4 Feb 11, 2022
Dashboard to monitor the performance of your Binance Futures account

futuresboard A python based scraper and dashboard to monitor the performance of your Binance Futures account. Note: A local sqlite3 database config/fu

86 Dec 29, 2022
doi, pubmed, arxiv.org的查询服务API接口,部署于vercel云函数

article-search-service doi, pubmed, arxiv.org的查询服务API接口,部署于vercel云函数 云函数 vercel,国内可能被qiang了。 DOI接口 POST https://article-search-service.vercel.app/api/

HyokaChen 2 Oct 10, 2021
A python bot that stops muck chains

muck-chains-stopper-bot a bot that stops muck chains this is the source code of u/DaniDevChainBreaker (the main r/DaniDev muck chains breaker) guys th

24 Jan 04, 2023
Coinbase Pro API interface framework and tooling

neutrino This project has just begun. Rudimentary API documentation Installation Prerequisites: Python 3.8+ and Git 2.33+ Navigate into a directory of

Joshua Chen 1 Dec 26, 2021
Lib for create and show QRCode to PIX, you can show this code in another applications for payment by final consumer.

Biblioteca para a geração de codigos QR (BRCode como chamados na documentação do BACEN) a fins de facilitar a exibição para pagamentos ao consumidor.

João Camargo 13 Oct 05, 2022
Unofficial Medium Python Flask API and SDK

PyMedium - Unofficial Medium API PyMedium is an unofficial Medium API written in python flask. It provides developers to access to user, post list and

Engine Bai 157 Nov 11, 2022
Provide fine-grained push access to GitHub from a JupyterHub

github-app-user-auth Provide fine-grained push access to GitHub from a JupyterHub. Goals Allow users on a JupyterHub to grant push access to only spec

Yuvi Panda 20 Sep 13, 2022
Python client and API for monitoring and controling energy diversion devices from MyEnergi

Python client and API for monitoring and controling energy diversion devices from MyEnergi A set of library functions and objects for interfacing with

1 Dec 17, 2021
Enables you to execute scripts and perform API requests in MikroTik router

HomeAssistant component: MikroTik API The mikrotik_api platform enables you to execute scripts and perform API requests in MikroTik router To enable M

Pavel S 6 Aug 12, 2022
An API serving data on all creatures, monsters, materials, equipment, and treasure in The Legend of Zelda: Breath of the Wild

Hyrule Compendium API An API serving data on all creatures, monsters, materials, equipment, and treasure in The Legend of Zelda: Breath of the Wild. B

Aarav Borthakur 116 Dec 01, 2022
AWS DeepRacer Free Student Workshop: Run faster by using your custom waypoints

AWS DeepRacer Free Student Workshop: Run faster by using your custom waypoints Reward Function Template for waypoints def reward_function(params):

Yuen Cheuk Lam 88 Nov 27, 2022