Skip to main content

A Discord API Wrapper for Userbots/Selfbots written in Python.

Project description

DisCum

version python versions
PyPI version python versions
A simple, easy to use, non-restrictive, synchronous Discord API Wrapper for Selfbots/Userbots written in Python.
-using requests and websockets :)

https://files.catbox.moe/3ns003.png

Currently don't have time to maintain this project.

I might edit from time to time. Feel free to fork the repo and make your own edits. For another python library that's currently better maintained, I'd recommend the following (asynchronous) lib: https://github.com/dolfies/discord.py-self
Happy coding,
- arandomnewaccount

*** risky actions: issue #66

Table of Contents

Key features

  • easy-to-use (make selfbots/userbots)
  • easy-to-extend/edit (add api wrappers)
  • readable (organized 😃 )
  • mimics the client while giving you control
  • all api wraps point to user/"private" apis
  • on-event (gateway) capabilities
  • extremely customizable fetchMembers function
  • remote authentication functions
  • support for python 2.7

About

Discum is a Discord self/userbot api wrapper (in case you didn't know, self/userbotting = automating a user account). Whenever you login to discord, your client communicates with Discord's servers using Discord's http api (http(s) requests) and gateway server (websockets). Discum allows you have this communication with Discord using python.

The main difference between Discum and other Discord api wrapper libraries (like discord.py) is that discum is written and maintained to work on user accounts (so, perfect for selfbots/userbots). We test code on here and develop discum to be readable, expandable, and useable. Functions that are risky to use are clearly stated as such in the docs.

Note, using a selfbot is against Discord's Terms of Service and you could get banned for using one if you're not careful. Also, this needs to be said: discum does not have rate limit handling. The main reasons for this are that discum is made to (1) be (relatively) simple and (2) give the developer/user freedom with how to handle the rate limits. We (Merubokkusu and anewrandomaccount) do not take any responsibility for any consequences you might face while using discum. We also do not take any responsibility for any damage caused (to servers/channels) through the use of Discum. Discum is a tool; how you use this tool is on you.

Installation

To install the library normally, run:

python -m pip install --user --upgrade git+https://github.com/Merubokkusu/Discord-S.C.U.M.git#egg=discum

Otherwise, to also use remote authentication functions (login using a phone & qr code), run:

python -m pip install --user --upgrade -e git+https://github.com/Merubokkusu/Discord-S.C.U.M.git#egg=discum[ra]

Prerequisites (installed automatically using above methods)

  • requests
  • requests_toolbelt
  • brotli
  • websocket_client==0.59.0
  • filetype
  • ua-parser
  • colorama

remote auth prerequisites (if you install discum[ra]):

  • pyqrcode
  • pycryptodome
  • pypng

Documentation

https://github.com/Merubokkusu/Discord-S.C.U.M/tree/master/docs

Contributing

Contributions are welcome. You can submit issues, make pull requests, or suggest features. Ofc not all suggestions will be implemented (because discum is intended to be a transparent, relatively-raw discord user api wrapper), but all suggestions will be looked into.
Please see the contribution guidelines

Example usage

import discum     
bot = discum.Client(token='420tokentokentokentoken.token.tokentokentokentokentoken', log=False)

bot.sendMessage("238323948859439", "Hello :)")

@bot.gateway.command
def helloworld(resp):
    if resp.event.ready_supplemental: #ready_supplemental is sent after ready
        user = bot.gateway.session.user
        print("Logged in as {}#{}".format(user['username'], user['discriminator']))
    if resp.event.message:
        m = resp.parsed.auto()
        guildID = m['guild_id'] if 'guild_id' in m else None #because DMs are technically channels too
        channelID = m['channel_id']
        username = m['author']['username']
        discriminator = m['author']['discriminator']
        content = m['content']
        print("> guild {} channel {} | {}#{}: {}".format(guildID, channelID, username, discriminator, content))

bot.gateway.run(auto_reconnect=True)

Links

Documentation
More examples
Changelog
GitHub
PyPi

Checklist

  • Sending basic text messages
  • Sending Images
  • Sending Embeds
  • Sending Requests (Friends etc)
  • Profile Editing (Name,Status,Avatar)
  • On-Message (and other on-anything gateway) capabilities
  • Getting guild members
  • improve documentation
  • add interactions (slash command triggering, buttons, and dropdowns/menus)
  • add more guild http api wraps
  • media (voice & video calls, along with the various discord games/activites)
  • Everything

FAQ

Q: Why am I getting Attribute Errors?
A: Most likely you've installed discum through pip, which is not always updated. To get the most recent version, install through github. For gateway.session related errors, you need to connect to the gateway at least once to receive session data.

Q: Does discum support BOT accounts?
A: No. Discum only supports user accounts.

Q: What's the difference between user/private API and BOT API?
A: User APIs are run by the official client. Many of these are not documented by discord. On the other hand, BOT APIs are run by BOT accounts and are documented by discord. Discum only consists of user APIs.

Q: How to fix "[SSL: CERTIFICATE_VERIFY_FAILED]" errors?
A: https://stackoverflow.com/a/53310545/14776493

Q: I'm getting KeyError: 'members' when running bot.gateway.session.guild(guild_ID).members. Why?
A: KeyErrors happened on previous versions where the "members" key was not set until you ran bot.gateway.fetchMembers(...); bot.gateway.run(). Due to this causing some confusion, the latest versions do not display this KeyError (instead, the value of "members" is an empty dictionary to start with). Of course, you still have to fetch the members (a gateway operation) in order to get the members.

Q: import _brotli ImportError: DLL load failed: The specified module could not be found. How to fix?
A: https://github.com/google/brotli/issues/782

Q: The owner of this website (discord.com) has banned your access based on your browser's signature.... How to fix?
A: This is because of your user agent (https://stackoverflow.com/a/24914742/14776493). Either try again or reinitialize your client with a new user agent.

Notes

In recent years, token logging has become more common (as many people don't check code before they run it). I've seen many closed-source selfbots, and while surely some are well intentioned, others not so much. Discum (discord api wrapper) is open-sourced and organized to provide transparency, but even so, we encourage you to look at the code. Not only will looking at the code help you to better understand how discord's api is structured, but it'll also let you know exactly what you're running. If you have questions about Discum (after looking at the docs & previous issues), free to ask us.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

discum-1.4.1.tar.gz (72.6 kB view details)

Uploaded Source

Built Distribution

discum-1.4.1-py3-none-any.whl (82.9 kB view details)

Uploaded Python 3

File details

Details for the file discum-1.4.1.tar.gz.

File metadata

  • Download URL: discum-1.4.1.tar.gz
  • Upload date:
  • Size: 72.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.12

File hashes

Hashes for discum-1.4.1.tar.gz
Algorithm Hash digest
SHA256 ffc4da0267d23efffb92eca6a1c912bc2daec578077ee3fe15737cbee03d5876
MD5 ab4a38510463ff31d1a62374560ac637
BLAKE2b-256 eed66952218b6e6d0e031e95750d961d9f82091b5d3cf61e9019775a905062f6

See more details on using hashes here.

File details

Details for the file discum-1.4.1-py3-none-any.whl.

File metadata

  • Download URL: discum-1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 82.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.12

File hashes

Hashes for discum-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ca548e38801589e739fdf454ed7e2572513f7392380eae62fe0d1df54e665a97
MD5 f408658b9e3632d00c8d89a6c50a8cb5
BLAKE2b-256 e9ca1880ee6c1b37b776d291cb37598273e0bfa5707a36fa5473243c89f68b71

See more details on using hashes here.

Supported by

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