{"id":13466684,"url":"https://github.com/shardlab/discordcr","last_synced_at":"2025-03-26T00:31:21.310Z","repository":{"id":41908867,"uuid":"312285753","full_name":"shardlab/discordcr","owner":"shardlab","description":"Minimalist Discord library for Crystal","archived":false,"fork":false,"pushed_at":"2023-12-07T02:19:30.000Z","size":3129,"stargazers_count":99,"open_issues_count":11,"forks_count":15,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-29T20:32:32.320Z","etag":null,"topics":["crystal","discord","hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"Crystal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shardlab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-12T13:31:10.000Z","updated_at":"2024-09-23T19:14:02.000Z","dependencies_parsed_at":"2023-12-07T03:25:11.695Z","dependency_job_id":"c4581e30-2c27-4c9f-95ca-22e47d6ee0d7","html_url":"https://github.com/shardlab/discordcr","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shardlab%2Fdiscordcr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shardlab%2Fdiscordcr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shardlab%2Fdiscordcr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shardlab%2Fdiscordcr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shardlab","download_url":"https://codeload.github.com/shardlab/discordcr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245566098,"owners_count":20636390,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crystal","discord","hacktoberfest"],"created_at":"2024-07-31T15:00:48.595Z","updated_at":"2025-03-26T00:31:20.918Z","avatar_url":"https://github.com/shardlab.png","language":"Crystal","funding_links":[],"categories":["API Libraries","Libraries"],"sub_categories":["Crystal"],"readme":"[![docs](https://img.shields.io/badge/docs-v0.4.0-green.svg?style=flat-square)](https://dcr.shardlab.dev/v0.4.0/) [![docs](https://img.shields.io/badge/docs-master-red.svg?style=flat-square)](https://dcr.shardlab.dev/master/)\n\n### Important Notice\nThis is the **new official source of discordcr**!\\\nThe [old repo](https://github.com/discordcr/discordcr) has not been updated for countless months\nand new features, along with library breaking changes, are coming fast.\\\nThere is no guarantee any code/updates will be pushed to the old repo again, so as it stands,\\\nthis will be where all new code will be pushed and where all new PRs and Issues should be created.\n\nThanks!\n\n# discordcr\n\n(The \"cr\" stands for \"creative name\".)\n\ndiscordcr is a minimalist [Discord](https://discord.com/) API library for\n[Crystal](https://crystal-lang.org/), designed to be a complement to\n[discordrb](https://github.com/shardlab/discordrb) for users who want more control\nand performance and who care less about ease-of-use.\n\ndiscordcr isn't designed for beginners to the Discord API - while experience\nwith making bots isn't *required*, it's certainly recommended. If you feel\noverwhelmed by the complex documentation, try\n[discordrb](https://github.com/shardlab/discordrb) first and then check back.\n\nUnlike many other libs which handle a lot of stuff, like caching or resolving,\nthemselves automatically, discordcr requires the user to do such things\nmanually. It also doesn't provide any advanced abstractions for REST calls;\nthe methods perform the HTTP request with the given data but nothing else.\nThis means that the user has full control over them, but also full\nresponsibility. discordcr does not support user accounts; it may work but\nlikely doesn't.\n\n## Installation\n\nAdd this to your application's `shard.yml`:\n\n```yaml\ndependencies:\n  discordcr:\n    github: shardlab/discordcr\n```\n\n## Usage\n\nAn example bot can be found\n[here](https://github.com/shardlab/discordcr/blob/master/examples/ping.cr). More\nexamples will come in the future.\n\nA short overview of library structure: the `Client` class includes the `REST`\nmodule, which handles the REST parts of Discord's API; the `Client` itself\nhandles the gateway, i. e. the interactive parts such as receiving messages. It\nis possible to use only the REST parts by never calling the `#run` method on a\n`Client`, which is what does the actual gateway connection.\n\nThe example linked above has an example of an event (`on_message_create`) that\nis called through the gateway, and of a REST call (`client.create_message`).\nOther gateway events and REST calls work much in the same way - see the\ndocumentation for what specific events and REST calls do.\n\nCaching is done using a separate `Cache` class that needs to be added into\nclients manually:\n\n```cr\nclient = Discord::Client.new # ...\ncache = Discord::Cache.new(client)\nclient.cache = cache\n```\n\nResolution requests for objects can now be done on the `cache` object instead of\ndirectly over REST, this ensures that if an object is needed more than once\nthere will still only be one request to Discord. (There may even be no request\nat all, if the requested data has already been obtained over the gateway.)\nAn example of how to use the cache once it has been instantiated:\n\n```cr\n# Get the username of the user with ID 66237334693085184\nuser = cache.resolve_user(66237334693085184_u64)\nuser = cache.resolve_user(66237334693085184_u64) # won't do a request to Discord\nputs user.username\n```\n\nApart from this, API documentation is also available, at\n\nhttps://dcr.shardlab.dev/v0.4.0 for v0.4.0\n\nhttps://dcr.shardlab.dev/master for latest\n\n## Contributing\n\n1. Fork it (https://github.com/shardlab/discordcr/fork)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [meew0](https://github.com/meew0) - creator, maintainer\n- [RX14](https://github.com/RX14) - Crystal expert, maintainer\n- [PixeL](https://github.com/PixelInc) - Maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshardlab%2Fdiscordcr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshardlab%2Fdiscordcr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshardlab%2Fdiscordcr/lists"}