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
AUDD IS MUSIC RECOGNITION API

AUDD IS MUSIC RECOGNITION API

Abdimk 1 Dec 15, 2021
Notion4ever - Python tool for export all your content of Notion page using official Notion API

NOTION4EVER Notion4ever is a small python tool that allows you to free your cont

50 Dec 30, 2022
Unofficial Python API client for Notion.so

notion-py Unofficial Python 3 client for Notion.so API v3. Object-oriented interface (mapping database tables to Python classes/attributes) Automatic

Jamie Alexandre 3.9k Jan 03, 2023
A file-based quote bot written in Python

Let's Write a Python Quote Bot! This repository will get you started with building a quote bot in Python. It's meant to be used along with the Learnin

1 Oct 28, 2021
TwitterBot-ImageCollector - Twitter bot that collects images from likes saves the image

TwitterBot-ImageCollector Bot de Twitter que recolecta imagenes a partir de los

Gx3 Studios 4 Jun 01, 2022
Trading Strategies (~50%) developed by GreenT on QuantConnect platform over the autumn quarter

Trading Strategies ~50% of codes from the Applied Financial Technology Course. Contributors: Claire W. Derrick T. Frank L. Utkarsh T. Course Leads: Dy

Utkarsh 2 Feb 07, 2022
🖥️ Python - P1 Monitor API Asynchronous Python Client

🖥️ Asynchronous Python client for the P1 Monitor

Klaas Schoute 9 Dec 12, 2022
Heroku app to explore boardgame data

A Dashboard for the Board Game Geeks among us Link to Application As many Board Game Geeks like myself track the scores of board game matches I decide

Maarten Grootendorst 20 Nov 23, 2022
Python library for generating sequences with uniform stimulus history

Sampling Euler tours for uniform stimulus history Table of Contents About Examples Experiment 1 Experiment 2 Experiment 3 Experiment 4 Experiment 5 Co

5 Nov 11, 2021
A Bot Upload file|video To Telegram using given Links.

A Bot Upload file|video To Telegram using given Links.

Hash Minner 19 Jan 02, 2023
A results generator and automatic token checker for Yandex Contest

Yandex contest Python checking tools A results generator and automatic token checker for Yandex Contest. Версия на русском языке Installation Clone th

Nikolay Chechulin 9 Dec 14, 2022
API Basica per a synologys Active Backup For Buissiness

Synology Active Backup for Business API-NPP Informació Per executar el programa

Nil Pujol 0 May 13, 2022
Userbot Telegram + Music Voice Chats. Dibuat Untuk Bersenang - Senang , Dan Mempermudah Kegiatan. Created By Rio.

RIO - USERBOT Disclaimer Saya tidak bertanggung jawab atas penyalahgunaan bot ini. Bot ini dimaksudkan untuk bersenang-senang sekaligus membantu Anda

RioProjectX 1 Nov 10, 2021
Fast and multi-threaded script to automatically claim targeted username including 14 day bypass

Instagram Username Auto Claimer Fast and multi-threaded script to automatically claim targeted username. Click here to report bugs. Usage Download ZIP

265 Dec 28, 2022
A cracking tool of Xiaomi Dr AI (Archytas / Archimedes)

Archytas Tool 我们强烈抵制闲鱼平台上未经授权的刷机服务! 我对本人之前在程序中为防止违规刷机服务添加未生效的格机代码感到抱歉,在此声明此过激行为与 Crack Mi Dr AI Team 无关,并将程序开源。 A cracking tool of Xiaomi Dr AI (Archy

rponeawa 5 Oct 25, 2022
Passive income method via SerpClix. Uses a bot to accept clicks.

SerpClixBotSearcher This bot allows you to get passive income from SerpClix. Each click is usually $0.10 (sometimes $0.05 if offer isnt from the US).

Jason Mei 3 Sep 01, 2021
Let your friends know when you are online and offline xD

Twitter Last Seen Activity Let your friends know when you are online and offline Laser-light eyes when online Last seen is mentioned in user bio Also

Kush Choudhary 12 Aug 16, 2021
Trellox Tool is written in Python3 and designed to pull and list Trello boards.

TrelloX Trellox Tool is written in Python3 and designed to list and pull Trello boards. It can be used by penetration testers/bug bounty hunters to de

Ali Fathi Ali Sawehli 1 Dec 05, 2021
WhatsApp Multi Device Client

WhatsApp Multi Device Client

23 Nov 18, 2022
Mazda Connected Service API wrapper based on pymazda and Flask.

Mazda Connected Service Relay Mazda Connected Service API wrapper based on pymazda and Flask. Usage Make POST calls to https://mymazda.herokuapp.com/{

Alan Chen 10 Jan 05, 2023