{"id":22555422,"url":"https://github.com/jaynightmare/level-discord-bot","last_synced_at":"2025-03-28T10:46:15.647Z","repository":{"id":254909594,"uuid":"847932914","full_name":"JayNightmare/Level-Discord-Bot","owner":"JayNightmare","description":"A discord bot that tracks users messages to gain points. A great way to encourage messaging engagement and interaction. Has milestone levels for users to gain roles, and has badges for reaching certain milestones.","archived":false,"fork":false,"pushed_at":"2025-02-06T23:37:56.000Z","size":248,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-19T20:54:47.917Z","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/JayNightmare.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":"2024-08-26T20:24:44.000Z","updated_at":"2025-02-06T23:38:00.000Z","dependencies_parsed_at":"2024-09-13T00:13:03.408Z","dependency_job_id":null,"html_url":"https://github.com/JayNightmare/Level-Discord-Bot","commit_stats":null,"previous_names":["jaynightmare/lvl-bot"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JayNightmare%2FLevel-Discord-Bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JayNightmare%2FLevel-Discord-Bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JayNightmare%2FLevel-Discord-Bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JayNightmare%2FLevel-Discord-Bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JayNightmare","download_url":"https://codeload.github.com/JayNightmare/Level-Discord-Bot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246015449,"owners_count":20709987,"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-12-07T19:07:50.143Z","updated_at":"2025-03-28T10:46:15.624Z","avatar_url":"https://github.com/JayNightmare.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"./image.png\" height=\"128\" \u003e\n\u003c/div\u003e\n\u003ch1 align=\"center\"\u003eLevelling Discord Bot\u003c/h1\u003e\n\u003cdiv align=\"center\"\u003e\n    \u003ca href=\"https://github.com/JayNightmare/Level-Discord-Bot/graphs/contributors\"\u003e\n      \u003cimg alt=\"GitHub Contributors\" src=\"https://img.shields.io/github/contributors/JayNightmare/Level-Discord-Bot?color=2db94d\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/JayNightmare/Level-Discord-Bot/issues\"\u003e\n      \u003cimg alt=\"Issues\" src=\"https://img.shields.io/github/issues/JayNightmare/Level-Discord-Bot?color=0088ff\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/JayNightmare/Level-Discord-Bot/pulls\"\u003e\n      \u003cimg alt=\"GitHub pull requests\" src=\"https://img.shields.io/github/issues-pr/JayNightmare/Level-Discord-Bot?color=0088ff\" /\u003e\n    \u003c/a\u003e\n    \u003cbr/\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003cdiv\u003e\n    \u003ca href=\"https://top.gg/bot/1278098225353719869\"\u003e\n      \u003cimg src=\"https://top.gg/api/widget/upvotes/1278098225353719869.svg\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://discord.com/application-directory/1278098225353719869\"\u003e\n      \u003cp\u003eDiscord App Directory\u003c/p\u003e\n    \u003c/a\u003e\n  \u003c/div\u003e\n\u003c/div\u003e\n\u003cbr/\u003e\n\u003cp align=\"center\"\u003eThis bot will keep track of user levels. Has anti spam measures and has commands for QOL\u003c/p\u003e\n\n## Have a bug?\nSubmit an `Issue` and tell me what's wrong.\n\n## Things to note before cloning\nThis code base uses discord.js, sqlite3, .env, and a few other npm packages. If you forget to import a one of these, an error WILL occur. I'm using `npm` so all imports will start with `npm install`.\n\nAll the things you need to import are:\n\u003e #### Absolutely Needed Imports:\n- discord.js@latest\n- -g npm (ensures node.js and npm are up to date)\n- dotenv (.env file type)\n\n\u003e #### For JSON Data Management Imports:\n- body-parser (for handling JSON request bodies)\n\n\u003e #### For SQLite Data Management Imports:\n- sqlite3 (or better-sqlite3 if you want to sync APIs, faster for more frequent queries)\n\n\u003e #### For MongoDB and Mongoose Data Management Imports:\n- mongodb mongoose\n\n\u003e #### For PostgreSQL (Relational) Imports:\n- pg\n\n\u003e #### Optional Imports: (if you choose to upload publicly)\n- axios (Promise-Based HTTP Client)\n- express (tool for HTTP servers)\n- dblappi.js (for top.gg API handles)\n- -g madge (to trace dependencies. Run `madge --circular ./path-to-your-project` to setup manually)\n\n## Installation Guide For JSON:\n### Step 1: Importing\nInstall the `Absolutely Needed Imports`. Using `dotenv` will keep your bot token secure in a `.env` file. Remember to add this file to the .gitignore file so you don't share your token by accident.\n\nYour `.env` should look similar to this:\n```js\n# Needed Variables\nTOKEN= # bot token\nTEST_TOKEN= # test bot token if you want to test before pushing to live\nCLIENT_ID= # bot client id\nOWNER= # your user id\n\n# Optional if you publish the bot to Top.gg\nTOPGG_API_KEY= # your webhook key on topgg\nTOPGG_TOKEN= # secret token on topgg\nHARDCODED= # bot client id\n```\n\n\u003e Optional:\n\nIf you want to enable vote tracking for the vote command, install the `optional imports` and in your `.env` put your webhook key in the variables above. \n\nIf you don't want voting, delete or comment out the `vote` command - it WILL throw errors at you.\n\n---\n\n### Step 2: File Management Setup\nIf you have choosen to use the JSON file type, you'll need to make sure you have a `json` folder with achievements, badges, owner, serverConfigs, and users json files.\n\nThe current code base is setup for sqlite3 but to convert it to json just change `utils.js` file with your json file logic. For example, if you wanted to insert data into the serverConfigsData json file, you would do:\n```json\n// Initialize server config data if it's not present\nif (!serverConfigsData[serverId]) {\n  serverConfigsData[serverId] = {\n      serverId: serverId,\n      name: guild.name,\n      blacklistedChannels: [],\n      allowedChannel: null,\n      loggingChannelId: null,\n      prefix: \"!\", // Default prefix\n      requireConfirm: false\n  };\n}\n```\n\nI've left this commented out in the admin_commands.js file in the `setlevels` command. Simply refactor the functions with that logic and you'll be set for json data management.\n\n---\n\n### Step 3:\nGo to the discord dev portal, make a bot and get the bot token. Location: `Bot -\u003e Token`. Copy the token and put it in your `.env` file.\n\n---\n\n### Step 4:\nGo back to the portal and go to `Bot -\u003e Privileged Gateway Intents` and enable all. Then go to `Installation -\u003e Installation Contexts` and enable `Guild Install`. Below that will be `Install Link`, use `Discord Provided Link`. Before copying to link, scroll down to `Default Install Settings`, you want to add\n- Scopes: `application.commands` and `bot`\n- Permissions: `Embed Links`, `Manage Messages`, `Manage Roles`, `Read Message History`, and `Send Messages` or `Administrator` for no conflict.\n\n### General Permissions:\n- **Administrator** (if you want the bot to have full control) or alternatively, you can selectively choose:\n  - **Manage Server** (if the bot needs to modify server settings)\n  - **Manage Roles** (for commands that set roles for users)\n  - **Manage Channels** (if the bot will create/manage channels)\n  - **View Audit Log** (if your bot will log server activities)\n\n### Text Permissions:\n- **Send Messages** (this is essential for sending commands/responses)\n- **Embed Links** (for sending rich embeds with detailed information)\n- **Manage Messages** (if you want the bot to delete or edit messages)\n- **Read Message History** (to respond to older messages)\n- **Use Slash Commands** (for enabling your bot to use slash commands)\n- **Mention Everyone** (if the bot needs to ping @everyone or specific roles)\n- **Add Reactions** (if your bot interacts via emoji reactions)\n\n### Voice Permissions:\nIf your bot needs to interact with voice channels, you might consider:\n- **Connect** (if the bot will join voice channels)\n- **Speak** (if the bot will speak in voice channels)\n\n---\n\n### Step 6:\nIf you run the bot, the data will generate into the files (json files in the json folder) except `serverConfigs.json` - This is a personal bug I kept coming across, my fix was to trigger the save in the `messageCreate` function in the `bot.js`.\n\n`owner.json` will hold all your debugging info. For example, mine tells me when a server receieves a bug and to push an update to the servers. I also have a `servercall` which allows me to use the server id to \"call\" the server and look at the data which is causing the error.\n\n---\n\n### Step 7:\nAfter all that, run `bot.js`. If you recieve errors, idk use ChatGPT 👁👄👁\n\n---\n\n## Installation Guide For SQLite3:\n### Step 1: Importing\nInstall the `Absolutely Needed Imports`. Using `dotenv` will keep your bot token secure in a `.env` file. Remember to add this file to the .gitignore file so you don't share your token by accident.\n\nYour `.env` should look similar to this:\n```js\n# Needed Variables\nTOKEN= # bot token\nTEST_TOKEN= # test bot token if you want to test before pushing to live\nCLIENT_ID= # bot client id\nOWNER= # your user id\n\n# Optional if you publish the bot to Top.gg\nTOPGG_API_KEY= # your webhook key on topgg\nTOPGG_TOKEN= # secret token on topgg\nHARDCODED= # bot client id\n```\n\n\u003e Optional:\n\nIf you want to enable vote tracking for the vote command, install the `optional imports` and in your `.env` put your webhook key in the variables above. \n\nIf you don't want voting, delete or comment out the `vote` command - it WILL throw errors at you.\n\n---\n\n### Step 2: File Management Setup\nIf you've choosen SQLite3, you'll need to install the `SQLite Data Management Imports`. Run the `setupDatabase.js` to setup the Database. If you're migrating data from JSON files, use the `migrateDataToDB.js` to push the data over to the tables. \n\nOnce you've setup the database, install a database viewer. There are two options:\n| Program Location | Recommended Program |\n|------------------|---------------------|\n| PC (Local View)  | [SQLite Browser](https://sqlitebrowser.org/dl/) |\n| Server (Remote View) | [SQLite Web](https://github.com/coleifer/sqlite-web) |\n\nFor the PC Local View, you can load the database and edit the data using a program on your pc. \n\nFor the Server Remote View, you need to:\n1. Open command prompt (or a terminal) and `ssh` into your server.\n1. Run `pip install sqlite-web` on your server _(make sure to also have python installed on the server)_.\n2. `cd` into your root folder of your bot and run `sqlite_web --port 8080 nameOfYourDatabase.db`.\n3. Open another command prompt (or terminal) and run `ssh -L 8000:localhost:8080 user@your-server-ip` so you can SSH Tunnel the connection to your machine. \n4. Go to your browser and enter `http://localhost:8000` into the URL bar and you'll be able to see your database.\n\nTo exit the database, just go back to the first command prompt and do `Crtl+C` to disconnect. If you encounter an error with connecting or the page not opening, try a different port or use ChatGPT to debug idk.\n\n---\n\n## Installation Guide For MongoDB and Mongoose or PostgreSQL:\nSimilar to the SQLite steps but uses the MongoDB and Mongoose or PostgreSQL framework. I don't provide steps for migrating the code for that but it's roughly the same and doesn't require _that_ much work.\n\n---\n\n## Modification Guide:\nCommands are split into 4 different files: Admin, Community, Configuration, and Owner. Owner is not in this file as it's for bot debugging, but the other 3 are. In there you can customize anything you want. \n\n## Commands:\nTo see the commands in discord, run the `help` command using `!` or your custom prefix. All the community comands have slash command support as well.\n\u003ccode align=center\u003e\n| Command             | Description                          |\n|---------------------|--------------------------------------|\n| `setrankchannel`    | Set the rank check channel.          |\n| `unsetrankchannel`  | Unset the rank check channel.        |\n| `setlogchannel`     | Set the log channel.                 |\n| `viewsettings`      | View current settings.               |\n| `blacklist`         | Blacklist channels.                  |\n| `unblacklist`       | Unblacklist channels.                |\n| `rank`              | View your rank.                      |\n| `checkrole`         | Check your roles.                    |\n| `setlevels`         | Set milestone levels.                |\n| `setroles`          | Set milestone roles.                 |\n| `help`              | Display help.                        |\n| `profile`           | Displays users server profile        |\n| `setbio`            | Set bio for profile                  |\n| `leaderboard`       | Displays server leaderboard          |\n| `setprefix`         | Set server prefix                    |\n| `toggleconfirm`     | Set to confirm when adding xp        |\n| `addachievement/rmachievement/setachievement`  | Add, remove, or set achievements for server          |\n| `addbadge/rmbadge/setbadge/viewbadge`          | Add, remove, or set badges for server              |\n\u003c/code\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaynightmare%2Flevel-discord-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaynightmare%2Flevel-discord-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaynightmare%2Flevel-discord-bot/lists"}