{"id":17347534,"url":"https://github.com/cryptiklemur/discord-bot-base","last_synced_at":"2025-04-14T21:02:04.026Z","repository":{"id":57212441,"uuid":"50639488","full_name":"cryptiklemur/discord-bot-base","owner":"cryptiklemur","description":"Base bot for Discord","archived":false,"fork":false,"pushed_at":"2016-04-18T05:21:44.000Z","size":2030,"stargazers_count":10,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-10T07:05:55.165Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/cryptiklemur.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}},"created_at":"2016-01-29T05:17:54.000Z","updated_at":"2025-03-07T08:52:55.000Z","dependencies_parsed_at":"2022-09-04T04:10:16.581Z","dependency_job_id":null,"html_url":"https://github.com/cryptiklemur/discord-bot-base","commit_stats":null,"previous_names":["cryptiklemur/discord-bot-base","aequasi/discord-bot-base"],"tags_count":95,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptiklemur%2Fdiscord-bot-base","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptiklemur%2Fdiscord-bot-base/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptiklemur%2Fdiscord-bot-base/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptiklemur%2Fdiscord-bot-base/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cryptiklemur","download_url":"https://codeload.github.com/cryptiklemur/discord-bot-base/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248173807,"owners_count":21059594,"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":[],"created_at":"2024-10-15T16:49:08.137Z","updated_at":"2025-04-14T21:02:03.965Z","avatar_url":"https://github.com/cryptiklemur.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# discord-bot-base\n\nThis is a base bot for Discord using Javascript.\n\n## Installation\n\n### Requirements\n\nThis module requires \n\nInstall with NPM\n\n```bash\nnpm install --save discord-bot-base\n```\n\n## Usage\n\nThe goal of this repository, is to make it simple to create a bot, and add on commands. To get started just create an\ninstance of [`Bot`](blob/master/src/Bot.js).\n\n```javascript\n'use strict';\n\nconst BaseBot = require('discord-bot-base');\nconst TestCommand = require('./src/Command/TestCommand')\n\nnew BaseBot.Bot('dev', true, {\n    admin_id:  '\u003cyour user id\u003e',\n    email:     '\u003cyour bot login\u003e',\n    password:  '\u003cyour bot password\u003e',\n    log_dir:   '\u003clocation of logs directory\u003e',\n    commands:  [TestCommand],\n    prefix:    \"!\",\n});\n```\n\nThe arguments passed to `Bot` are first, the `environment` (generally 'dev' or 'prod'), `debug` (adds extra logging), and \nan array of `options`. \n\n*The keys that are provided to `options` (`admin_id`, `email`, `password`, `commands`, and `prefix` are all required).*\n\nBelow is a list of options you can pass:\n\n* `name` - Name of the bot. This is just for the output on the CLI. Not necessary, and will default to `discord-base-bot`\n* `version` - Version of the bot. This is also just for the output on the CLI. Not necessary, and will default to the current version of `discord-base-bot`\n* `author` - Author of the bot. This is again, just for the output on the CLI. Not necessary, and will default to the author of `discord-base-bot`\n* `status` - Status of the bot. Will show up in the user list as \"Playing \u003cstatus\u003e\"\n* `email` - Login for the bot. This is required.\n* `password` - Password for the bot. This is required.\n* `prefix` - Prefix the bot will use for commands. This is required. Try not to use common characters if you plan to be on big servers.\n* `admin_id` - User ID of the account you want to have access to admin commands. (e.g. the restart command)\n* `container` - Advanced. For now, if you need to add this, message me in the discord api server. Required to use mysql/mongo/redis stuff.\n* `commands` - An array of commands. The array should contain modules of commands. Check out an example below of a command.\n* `mongo_url` - a Fully qualified mongo dsn. e.g. `mongodb://localhost/`\n* `redis_url` - a Fully qualified redis dsn. e.g. `redis://localhost/`\n* `queue` - An object of config variables for [rabbitmq](https://github.com/postwait/node-amqp#connection-options-and-url)\n\nIf you specify queue, you will be able to set up your bot with cluster support, with PM2.\n\n### Command Example\n\nBelow, is what the Stats command looks like:\n\n```javascript\nconst AbstractCommand = require('discord-base-bot').AbstractCommand;\n\nclass StatsCommand extends AbstractCommand {\n    static get name() { return 'stats'; }\n\n    static get description() { return \"Shows the bot stats\"; }\n\n    handle() {\n        this.responds(/^stats$/g, () =\u003e {\n            let servers  = this.client.servers.length,\n                channels = this.client.channels.length,\n                users    = this.client.users.length,\n                online   = this.client.users.filter(u =\u003e u.status != \"offline\").length;\n\n            this.reply(\n                `Currently joined to: ${servers} servers with ${online}/${users} members and ${channels} text channels.`\n            );\n        });\n    }\n}\n\nmodule.exports = StatsCommand;\n```\n\nTake note of the static getters at the top. These are used for the help command.\n\nAll commands are required to extend [`AbstractCommand`](blob/master/src/Command/AbstractCommand.js). AbstractCommand provides a couple helper methods.\nA few to note are:\n\n* `responds` - Used when you want the bot to respond to a direct mention, or command. Takes a regex, with the second argument being a callback if a match was found. The callback is passed an array of matches.\n* `hears` - Used when you want the bot to listen for a phrase. Takes a regex, with the second argument being a callback if a match was found. The callback is passed an array of matches.\n* `sendMessage` - Shortcut for discord.js's client.sendMessage\n* `reply` - Shortcut for discord.js's client.reply, just pass a message.\n* `isThrottled` - Lets you throttle commands. Pass a key, and how long (in seconds) to throttle for.\n* `handle` - This method is required for all commands as well. All your logic should go in here.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcryptiklemur%2Fdiscord-bot-base","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcryptiklemur%2Fdiscord-bot-base","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcryptiklemur%2Fdiscord-bot-base/lists"}