{"id":14983347,"url":"https://github.com/grogsile-inc/djs-framework","last_synced_at":"2026-02-12T08:01:47.266Z","repository":{"id":57127544,"uuid":"431906599","full_name":"grogsile-inc/djs-framework","owner":"grogsile-inc","description":"This framework wraps around the Discord.js package to make creating a bot with Slash Commands as easy as possible.","archived":false,"fork":false,"pushed_at":"2022-10-30T02:53:01.000Z","size":249,"stargazers_count":5,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"stable","last_synced_at":"2025-09-21T18:04:04.764Z","etag":null,"topics":["discord","discord-framework","discord-js","djs","framework","hacktoberfest","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grogsile-inc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"medallyon","ko_fi":"medallyon"}},"created_at":"2021-11-25T16:14:32.000Z","updated_at":"2023-09-08T10:51:19.000Z","dependencies_parsed_at":"2023-01-20T19:19:11.120Z","dependency_job_id":null,"html_url":"https://github.com/grogsile-inc/djs-framework","commit_stats":null,"previous_names":["medallyon/djs-framework"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/grogsile-inc/djs-framework","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grogsile-inc%2Fdjs-framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grogsile-inc%2Fdjs-framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grogsile-inc%2Fdjs-framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grogsile-inc%2Fdjs-framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grogsile-inc","download_url":"https://codeload.github.com/grogsile-inc/djs-framework/tar.gz/refs/heads/stable","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grogsile-inc%2Fdjs-framework/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29361810,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T01:03:07.613Z","status":"online","status_checked_at":"2026-02-12T02:00:06.911Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["discord","discord-framework","discord-js","djs","framework","hacktoberfest","nodejs"],"created_at":"2024-09-24T14:07:05.752Z","updated_at":"2026-02-12T08:01:47.232Z","avatar_url":"https://github.com/grogsile-inc.png","language":"JavaScript","funding_links":["https://github.com/sponsors/medallyon","https://ko-fi.com/medallyon"],"categories":[],"sub_categories":[],"readme":"# djs-framework\nThis framework wraps around the Discord.js package to make creating a bot with Slash Commands as easy as possible. The main purpose is to remove the strain of trying to figure out how to use Slash Commands.\n\n## Contributing\nPlease submit issues if you find a bug, have some valuable feedback or feature requests, or if you have a question. Feel free to create a pull request if you would like to directly contribute to the project!\n\n## Getting Started\nFirst things first, `require` this package:\n\n```js\nconst { DiscordCommand, DiscordEvent } = require(\"@medallyon/djs-framework\");\n```\n\nBefore using any of the examples below, we also need to create a Discord.js Client instance, as per the [documentation](https://discord.js.org/#/docs/main/stable/general/welcome):\n\n```js\nconst { Client, Intents } = require(\"discord.js\");\n\n// Create the client\nconst client = new Client({\n    // Don't forget your Intents\n    intents: [ Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES ]\n});\n\n// You can call login whenever\nclient.login(process.env.DISCORD_TOKEN)\n    .then(() =\u003e console.log(\"I'm logged in!\"))\n    .catch(console.error);\n```\n\n### Discord Events\nSetup event listeners and pass in middleware functions. See [discord.js#Client](https://discord.js.org/#/docs/main/stable/class/Client) for a list of events and their arguments.\n\nTo setup an event listener for, say, the `messageCreate` event:\n```js\n// Create a middleware function for an event\nfunction log({ author, content })\n{\n    console.log(`${author.username}: \"${content}\"`);\n    // Prints: Medallyon: \"There is no way a bee should be able to fly.\"\n}\n\n// Then, create a new DiscordEvent instance and supply the Event Name, the Client, and any Options\nnew DiscordEvent(\"messageCreate\", client, { middleware: [ log ] });\n\n/**************\n       OR\n **************/\n\n// Create your DiscordEvent instance and store it\nconst onMessageCreate = new DiscordEvent(\"messageCreate\", client);\n\n// And register any middleware after creating your DiscordEvent\nonMessageCreate.registerMiddleware(log);\n```\n\n**Note** that the `messageCreate` event will become a privileged intent starting [April 30, 2022](https://support-dev.discord.com/hc/en-us/articles/4404772028055-Message-Content-Privileged-Intent-for-Verified-Bots).\n\n**Note** that events with the same name will be de-duplicated and destroyed.\n\n### Slash Commands\nYou can easily create slash commands with this framework. Here is an example:\n\n```js\n// Create a class that inherits DiscordCommand for your chosen Command\nclass Ping extends DiscordCommand\n{\n    constructor(client)\n    {\n        super(client, {\n            name: \"ping\",\n            description: \"Pong!\",\n\n            // The 'interaction' property defines your Slash Command\n            interaction: {\n                options: [\n                    {\n                        type: Constants.ApplicationCommandOptionTypes.BOOLEAN,\n                        name: \"pong\",\n                        description: \"Pong?\",\n                        required: false\n                    }\n                ]\n            }\n        });\n    }\n\n    // The 'run' method is always required\n    async run(interaction)\n    {\n        // The bot responds with \"Pong!\" or \"Ping?...\" based on if the user supplied the 'pong' option\n        const pong = interaction.options.getBoolean(\"pong\") ? \"Ping?...\" : \"Pong!\";\n        await interaction.reply({ content: pong });\n    }\n}\n\n// Create an instance of your custom Command\nnew Ping(client);\n```\n\nOnce you're happy with your Command modules, call `DiscordEvent.updateInteractions`:\n```js\n// Call this to update your Slash Commands after you have declared all of your custom Commands\nDiscordCommand.updateInteractions(process.env.DISCORD_BOT_ID, process.env.DISCORD_TOKEN);\n```\n\n## API\n\n### `DiscordEvent`\nThe constructor for `DiscordEvent` takes 3 arguments:\n\n+ `eventName` | `\u003cstring\u003e` - the Event Name to subscribe to. See [discord.js#Client](https://discord.js.org/#/docs/main/stable/class/Client) for a list of events.\n+ `client` | `\u003cDiscord.Client\u003e` - the Discord.js Client instance that you will use as the main client throughout your project\n+ `options` | `\u003cObject\u003e` (optional)\n  + `on` | `\u003cstring\u003e` - a choice between `\"on\"` or `\"once\"`. Read up on what this means [here](https://nodejs.org/api/events.html#handling-events-only-once).\n  + `middleware` | `\u003cArray\u003cfunction\u003e\u003e` - an array of middleware functions that should be executed when this event is triggered\n\n#### Fields\n\n+ `name` | `\u003cstring\u003e` - the event name for this event listener\n+ `client` | `\u003cDiscord.Client\u003e` - the Discord.js Client\n+ `on` | `\u003cstring\u003e` - the method of subscription to this event\n+ `middleware` | `\u003cArray\u003cfunction\u003e\u003e` - the Array of middleware functions that are run when this event is triggered\n\n#### Methods\n\n##### `registerMiddleware(cb)`\nThis method adds a function to the list of middleware functions that are executed when the event for a particular event listener is triggered. It takes 1 argument:\n\n+ `cb` | `\u003cfunction\u003e` - the middleware callback function for this event. Any arguments are passed into the function depending on the type of event.\n\n##### `destroy()`\nThis method destroys this event listener. It takes no arguments.\n\n### `DiscordCommand`\nThe constructor for `DiscordCommand` takes 2 arguments:\n\n+ `client` | `\u003cDiscord.Client\u003e` - the Discord.js Client\n+ `meta` | `\u003cObject\u003e` - info associated with this command\n  + `name` | `\u003cstring\u003e` - the name of the command\n  + `description` | `\u003cstring\u003e` - a description for this command\n  + `interaction` | `\u003cObject\u003e` - an [Application Command Object](https://discord.com/developers/docs/interactions/application-commands#create-global-application-command)\n  + `system` (optional) - whether this is a system-only command. If `true` | `\u003cbool\u003e`, this command will not be added as a Slash Command.\n  + `example` | `\u003cstring\u003e` (optional) - an example string of how this command might be used\n\n#### Fields\n\n+ `client` | `\u003cDiscord.Client\u003e` - the Discord.js Client\n+ `name` | `\u003cstring\u003e` - the name of this command\n+ `description` | `\u003cstring\u003e` - the description for this command\n+ `interaction` | `\u003cObject?\u003e` - the Application Command object for this interaction\n\n#### Properties\n\n+ `id` | `\u003cSnowflake?\u003e` - the ID of this command\n\n#### Methods\n\n##### `run(interaction)`\nWhen constructing your Command class, you should put any logic for your command in here. This method takes 1 argument:\n\n+ `interaction` | `\u003cInteraction\u003e` - See [Interaction](https://discord.js.org/#/docs/main/13.3.0/class/Interaction)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrogsile-inc%2Fdjs-framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrogsile-inc%2Fdjs-framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrogsile-inc%2Fdjs-framework/lists"}