A high level library for building Discord bots.

Overview

Qord

A high level library for building Discord bots.

🚧 This library is currently in development.

Questions that you are having

  • What is this?

    This is yet another library for Discord Bots API. This is not a finished project and is currently in it's development phase.

  • Why create another library?

    After discord.py archive, I could not find a library that I could use to develop my bots in future so here we are. As it may sound, This is definitely not a personal project, See below.

  • Is this going to be a publicly available library?

    Yes, It will be a public library but currently it is not finished and not in state of being released publicly. You can still install a very unstable version of this library (pip install qord) and hack it (Instructions in CONTRIBUTING file).

  • Can I contribute?

    That would be much appreciated! See Contributing Guidelines for more information and to get yourself familiar with the project.

  • When will this be finished?

    No idea yet; but soon ™️

  • Documentation?

    Yes. https://qord.readthedocs.io

  • I have more questions

    Join our Discord server: https://discord.gg/sRmvezKwD4

Comments
  • Implement ratelimits handling

    Implement ratelimits handling

    This pull request adds support for handling and prevention of ratelimits.

    • [x] Delaying requests on hitting 429s
    • [x] Global ratelimit handling
    • [x] Delay requests when a ratelimit bucket is exhausted.
    • [x] Use X-Ratelimit-Bucket (ratelimit key, as referred in code) for precise handling of ratelimits between routes that share same ratelimit.
    • [x] ~~Add hooks for ratelimits.~~
    • [x] Extensive testing.
    t: feature p: high s: testing needed 
    opened by izxxr 4
  • Expose raw HTTP methods to users.

    Expose raw HTTP methods to users.

    The current problem is that in order to perform simple HTTP operations, the instance of relevant Discord model is required. When the model is obtainable from cache, there are no problems but when the model isn't available in cache, It leads to issues of making more than one API call in order to fetch the resource and perform the wanted operation on it.

    For example to edit a message that is not in cache, the current solution is:

    message = await channel.fetch_message(123) # first API call
    await message.edit(**kwargs) # second API call
    

    This has an impact on bots who don't have specific intents enabled and in larger bots, this can impact ratelimits of the bot.

    For this purpose, there should be "raw" HTTP methods that allow you to make direct API calls to specific endpoints without fetching the relevant resource first. Taking the same example as above, The raw HTTP methods would allow the message editing in a single API call:

    await client.rest.edit_message(channel_id=123, **kwargs)
    

    Preferred Solution

    The current preferred solution is to expose the existing "internal" RESTClient class to the users. However as it is right now, it takes raw payloads for JSON body and returns raw response. We would have to refactor this class to be more user friendly in order to implement this feature.

    t: feature p: low l: breaking change 
    opened by izxxr 1
  • Rework library documentation

    Rework library documentation

    This pull request reworks the library documentation to be more easy to navigate and consistent.

    Following major changes have been made so far to the documentation and more are currently in progress:

    • Restructure the API reference into multiple sections.
    • Adds a "Getting Started" page on the documentation that currently mimics the GitHub readme but would contain a detailed intro to getting started with library and Discord bots in general.
    • Adds a better and detailed explanation to various features of the library that were left improperly documented.
    • Fixes position of various functions and classes in the API reference.
    • Moves contribution guidelines to documentation for ease of maintaining

    Feedback would be appreciated.

    t: documentation p: high 
    opened by izxxr 0
  • Fix instance checking for aiohttp.ClientSession

    Fix instance checking for aiohttp.ClientSession

    https://github.com/nerdguyahmad/qord/blob/c8398b25773c0ea7b2ea1a1696079dad2834434b/qord/core/rest.py#L55-L56

    If you check the above piece of code, you can clearly see that it raises a TypeError error if the session is an instance of aiohttp.ClientSession

    Suggested change:

    Change line 55 to this:

        if session and not isinstance(session, aiohttp.ClientSession):
    
    t: bug p: high 
    opened by UnrealFar 0
  • Message data gets overwritten during MESSAGE_UPDATE

    Message data gets overwritten during MESSAGE_UPDATE

    During the MESSAGE_UPDATE event, the message data gets overwritten and various values get the value of None or invalid default values. According to Discord documentation, This is because Discord often sends partial message data in MESSAGE_UPDATE event. Library should implement a way of only update the data that is sent by Discord rather than overwriting previously cached data.

    t: bug p: high 
    opened by izxxr 0
  • Provide raw event data on gateway event objects

    Provide raw event data on gateway event objects

    The library should provide raw event properties in the event object for the events sent over gateway.

    The purpose of this is to allow events to be somewhat independent of client's cache. This will be a workaround for the issue of missing the events that need certain entity to be cached, the most important example is message events that require message instance to be cached by the client.

    This feature is a breaking change in the sense that if your bot is missing some gateway intents, some events may dispatch with incomplete data. This would be case for many *_UPDATE and *_DELETE events. In an example of MESSAGE_UPDATE event:

    @client.event(GatewayEvent.MESSAGE_UPDATE)
    async def on_message_update(event):
      # event.message can be None if message is not cached but 
      # message_id is always present.
    
      if event.message is None:
        message = await event.channel.fetch_message(event.message_id)
      else:
        message = event.message
    
      ...
    

    The possibility of encountering an event with incomplete data is high for events like MESSAGE_UPDATE, MESSAGE_DELETE and other events that are dependent on an entity that is often not cached like messages. Whereas for events like GUILD_UPDATE, CHANNEL_CREATE and other events that are dependent on a "persistent" cache will almost never have incomplete data. The documentation would also be updated to properly reflect all possible edge cases related to events in simpler wording.

    This design is not yet finalized and there may be more changes.

    t: feature p: high l: breaking change s: planning needed 
    opened by izxxr 2
  • Add support for modifying cache behaviour.

    Add support for modifying cache behaviour.

    Currently, In order to modify the behaviour of cache, the only possible way is to write a custom cache handler implementation. However for users who are relying on default cache, this would be an overkill. This is why, A "cache settings" feature should be added that allows you to define specific common options for caching like message cache limit, private channels etc.

    A simple concept:

    cache_settings = qord.CacheSettings(
      message_limit=...,
      private_channel_limit=...,
    )
    client = qord.Client(cache_settings=cache_settings)
    

    These settings would be handled and checked by the library internally when caching entities and wouldn't require custom implementations to implement a logic for them.

    Options:

    These are current options in mind that would be able to be customised.

    • message_limit: Number of messages to cache at a time.
    • private_channel_limit: Number of private channels to cache at a time.
    • cache_message_users: Whether to cache user entities from message creates until the message is cached.

    Feedback on what options should be added would be appreciated.

    t: feature p: low 
    opened by izxxr 0
Releases(0.4.0)
  • 0.4.0(Apr 17, 2022)

    Additions

    • Added support for guild scheduled events.
    • Added support for stage instances.
    • Added following shortcut properties to Guild:
      • afk_channel
      • system_channel
      • widget_channel
      • rules_channel
      • public_updates_channel

    Fixes

    • Fix crash with KeyError during MESSAGE_UPDATE event.
    Source code(tar.gz)
    Source code(zip)
  • 0.3.0(Apr 13, 2022)

    Additions

    • Added support for custom guild emojis.
    • Added support for message reactions.
    • Added Guild.me property for retreiving bot member.
    • Added created_at property on appropriate Discord models.
    • Added BaseMessageChannel.messages method to iterate through channels history.
    • Added Guild.members method to iterate through guild members.
    • Added PrivateChannel.url, GuildChannel.url and Message.url properties
    • Added BaseMessageChannel.trigger_typing and BaseMessageChannel.typing for working with typing indicators.
    • Added Message.crosspost for crossposting messages in news channels.

    Changes

    • ChannelPermission now supports equality comparisons.
    • All models now shows useful information in repr()

    Fixes

    • Fixed Embed.video property running into infinite loop.
    • Fixed disparity between embed and embeds parameters in BaseMessageChannel.send
    • Fixed typing of Message.channel not including DM channels.
    Source code(tar.gz)
    Source code(zip)
  • 0.3.0a2(Apr 6, 2022)

    This release brings many new features such as ratelimits handling, permissions support etc. as well as many bug fixes. This would most likely be the last alpha release for v0.3 and next release would be stable v0.3.0!

    The major outlines for this release are given below:

    Additions

    • Added handling of HTTP ratelimits.
    • Added support for channel permission overwrites.
    • Added equality comparison support for various Discord models.
    • Added module qord.utils, see API reference for more info.
    • Added Message.referenced_message attribute.
    • Added qord.utils.create_timestamp helper function.
    • Added Embed.total_length and builtins.len() support on Embed
    • Added channel keyword argument in GuildMember.edit

    Improvements/Misc.

    • User.mention string no longer includes !, This is done in order to comply with the recent change done to Discord client. For more information, see this issue
    • DefaultCache.private_channels cache is now bound to limit of 256 channels.
    • File constructor no longer raises RuntimeError on failing to resolve file name and now fallbacks to untitled

    Fixes

    • Fixed cache not cleaning up on client closure.
    • Fixed typing issues across the library.
      • Passing None is not supported in various places especially x_url() methods.
      • None is now allowed in reason parameters in REST methods.
      • Various methods of cache handlers now return typing.List rather than the typing.Sequence
      • Other minor improvements and fixes.
    • Fixed GuildCache.roles returning empty list for HTTP retrieved guilds.
    • Minor bug fixes.
    Source code(tar.gz)
    Source code(zip)
  • 0.3.0a1(Mar 13, 2022)

    Breaking Changes:

    • Event system restructure

      • Custom events are now created using BaseEvent
      • Client.invoke_event() now takes single BaseEvent instance.
      • BaseEvent is no longer a protocol, all custom events must inherit it.
      • New protocol class BaseGatewayEvent has been added for gateway related events.
    • MessagesSupport was renamed to BaseMessageChannel for consistency.

    Additions:

    • Add MessageType enumeration.
    • Add support for message embeds.
    • Add support for message allowed mentions.
    • Add support for message flags.
    • Add support for message references.
    • Add Message.edit() and Message.delete() methods.
    • Add Shard.disconnect() and reconnect() methods.
    • Add PrivateChannel.close() method.
    • Add Intents.message_content privileged intent flag.
    • send() now supports embeds, files, allowed mentions and all other fields.

    Fixes:

    • Fix various crashes on startup.
    • Fix minor bugs.

    Improvements:

    • Startup time has minor improvements.
    • Library is now completely typed, there may be breaking type changes.
    Source code(tar.gz)
    Source code(zip)
  • 0.2.0(Mar 5, 2022)

    What's New

    • Added support for guild roles.
    • Added support for guild members.
    • Added support for permissions.
    • Added support for guild channels.
    • Added support for messages.
    • Added User.proper_name property.
    • Added User.mention property.

    Tweaks

    • Guild.cache is no longer optional.
    • Startup time has been significantly improved.

    Bug fixes

    • Fixed GuildCache.clear() not getting called upon guild evictions.
    • Fixed extension parameter incorrectly behaving for various URL methods.
    • Fixed shards closing on receiving unhandleable OP code.
    • Fixed client not properly closing in some cases.
    • Fixed Client.launch() raising RuntimeError upon relaunching the client after closing.

    Commits since previous version: https://github.com/nerdguyahmad/qord/compare/0.2.0a1...0.2.0

    Source code(tar.gz)
    Source code(zip)
  • 0.2.0a1(Feb 16, 2022)

    Changelog

    • Add support for users. (#2)
    • Add support for guilds. (#4)
    • Add support for caching. (#5)
    • Fix wrong instance check on manually passing a client session. (#3)
    • Event listeners tasks now have proper exception handling.
    • Various performance improvements.
    Source code(tar.gz)
    Source code(zip)
  • v0.1.0-alpha(Feb 8, 2022)

Owner
Izhar Ahmad
Izhar Ahmad
An EmbedBuilder for Discord bots in Python.

An EmbedBuilder for Discord bots in Python. You need discord.py to use this module.

null 6 Jan 13, 2022
A frame to create discord bots (for myself) that uses cogs, JSON, activities, and more.

dpy-frame A frame to create discord bots (for myself) that uses cogs, JSON, activities, and more. NOTE: Documentation is incomplete, so please wait un

Apple Discord 1 Nov 6, 2021
A pypi package that helps in generating discord bots.

A pypi package that helps in generating discord bots.

PineCode Corp 3 Nov 17, 2021
A pypi package that helps in generating discord bots.

A pypi package that helps in generating discord bots.

KlevrHQ 3 Nov 17, 2021
Often discord bots just die, and we hardly find one that is durable

Muitas vezes bots do discord simplesmente morrem, e dificilmente achamos um que seja durável. Então porque não ter um próprio para emergências? Como c

Guilherme Almeida 3 Dec 6, 2022
Discord bots that update their status to the price of any coin listed on x.vite.net

Discord bots that update their status to the price of any coin listed on x.vite.net

5am 3 Nov 27, 2022
Many discord bots serving different purposes

Discord_Botlari Farklı amaçlara hizmet eden bir çok discord botu En kapsamlı Bot Game Bottur. bir oyun botudur discord sunucularında kullanılır. (tüm

null 1 Dec 21, 2021
A simple tool which automate commands of discord economy bots

A simple tool which automate commands of discord economy bots. Fully configurable using an intuitive configuration made in YAML

SkydenFly 5 Sep 18, 2022
Discord spam bots with multiple account support and more

Discord spam bots with multiple account support and more. PLEASE READ EVERYTHING BEFORE WRITING AN ISSUE!! Server Messages Text Image Dm Messages Text

Mr. Nobody 6 Sep 14, 2022
Music cog for discord bots. Supports YouTube, YoutubeMusic, SoundCloud and Spotify.

dismusic Music cog for discord bots. Supports YouTube, YoutubeMusic, SoundCloud and Spotify. Installation python3 -m pip install dismusic Usage from d

Md Shahriyar Alam 59 Jan 8, 2023
A python library for building user interfaces in discord.

blurple.py A front-end framework for discord.py Blurple.py is a framework built on top of discord.py, giving you the tools you need to build discord b

null 4 Oct 25, 2021
Pure Python 3 MTProto API Telegram client library, for bots too!

Telethon ⭐️ Thanks everyone who has starred the project, it means a lot! Telethon is an asyncio Python 3 MTProto library to interact with Telegram's A

LonamiWebs 7.3k Jan 1, 2023
This is a unofficial library for making bots in rubika.

rubika this is a unofficial library for making bots in rubika using this library you can make your own0 rubika bot and control that those bots that ma

Bahman 50 Jan 2, 2023
It's a Discord bot to control your PC using your Discord Channel or using Reco: Discord PC Remote Controller App.

Reco PC Server Reco PC Server is a cross platform PC Controller Discord Bot which is a modified and improved version of Chimera for Reco-Discord PC Re

Arvinth Krishna 12 Aug 31, 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
Satoshi is a discord bot template in python using discord.py that allow you to track some live crypto prices with your own discord bot.

Satoshi ~ DiscordCryptoBot Satoshi is a simple python discord bot using discord.py that allow you to track your favorites cryptos prices with your own

Théo 2 Sep 15, 2022
Discord bot script for sending multiple media files to a discord channel according to discord limitations.

Discord Bulk Image Sending Bot Send bulk images to Discord channel. This is a bot script that will allow you to send multiple images to Discord channe

Nikola Arbov 1 Jan 13, 2022
DeKrypt 24 Sep 21, 2022