### Bot Configuration and Startup Source: https://context7.com/jamesconrad/discord-voice-normalizer/llms.txt Defines the main configuration file (config.json) and provides commands for starting the Discord bot, including options for auto-updates and restarts. ```json { "prefix": "!", "token": "YOUR_DISCORD_BOT_TOKEN", "botUID": "YOUR_BOT_USER_ID", "dbfile": "db/primary.db", "minSampleVoldB": 40, "triviaTimeout": 15000, "triviaRepeatDelay": 3000, "month": 3, "auto_update": false, "activity_logging": true, "enableErrorReportingToChannel": false, "errorReportChannelID": "CHANNEL_ID_FOR_ERRORS" } ``` ```bash # Starting the bot node index.js # With auto-updates and auto-restart (using bot.sh) ./bot.sh ``` -------------------------------- ### Database Module Usage (Node.js) Source: https://context7.com/jamesconrad/discord-voice-normalizer/llms.txt Demonstrates how to use the database module in Node.js to interact with the SQLite database. Includes examples for getting and updating guild configurations, running raw SQL queries, and fetching single or multiple rows using callbacks and promises. ```javascript // Database schema // guilds table CREATE TABLE guilds ( guild_id TEXT PRIMARY KEY, name TEXT, total_score INT, prefix TEXT, disabled_modules INT ); // guild_members table CREATE TABLE guild_members ( guild_id TEXT, user_id TEXT, FOREIGN KEY (guild_id) REFERENCES guilds(guild_id) ); // users table CREATE TABLE users ( user_id TEXT PRIMARY KEY, name TEXT, score INT, monthlyScore INT, FOREIGN KEY (user_id) REFERENCES guild_members(user_id) ); // Usage in modules: const database = require('./modules/database'); // Get guild configuration let cfg = database.GetGuildConfig(guild.id); console.log(cfg.prefix); // "!" console.log(cfg.disabled_modules); // 0 // Update guild configuration cfg.prefix = "$"; database.UpdateGuildConfig(cfg); // Run SQL queries database.run(`UPDATE users SET score = score + 1 WHERE user_id = ${userId}`); // Get single row with callback database.get(`SELECT * FROM users WHERE user_id = ${userId}`, (row) => { console.log(row.score); }); // Get multiple rows with promise let results = await database.allPromise(`SELECT * FROM guilds`, async (res) => { return res.sort((a, b) => b.total_score - a.total_score); }); ``` -------------------------------- ### Trivia Module Commands Source: https://context7.com/jamesconrad/discord-voice-normalizer/llms.txt Handles the trivia game, allowing users to start questions, view categories, and check scores. It integrates with OpenTDB API and supports per-server leaderboards. ```text User: !trivia Bot: [Embed] Title: What is the capital of France? Category: Geography Difficulty: easy Possible Answers: A - London B - Paris C - Berlin D - Madrid [After timeout] Answer: B - Paris Correct Players: Alice, Bob Disqualified Players: Charlie # With category and repeat: User: !trivia -c 9 -r 5 -d medium # Plays 5 medium-difficulty questions from category 9 (General Knowledge) # List categories: User: !trivia -categories Bot: Possible categories are: General Knowledge, ID: 9 Entertainment: Books, ID: 10 Entertainment: Film, ID: 11 ... # View scores: User: !trivia -score Bot: [Embed] ServerName Trivia Scores All Time Top Players: Alice: 45 Bob: 32 Monthly Top Players: Alice: 12 Bob: 8 ``` -------------------------------- ### Change Command Prefix for Discord Server Source: https://context7.com/jamesconrad/discord-voice-normalizer/llms.txt Allows administrators to change the command prefix for the current server. Requires Administrator permission. The bot confirms the change and provides an example of using the new prefix. ```text User: !changeprefix $ Bot: Command prefix has been changed to: $ # Now all commands use $ prefix: User: $help ``` -------------------------------- ### Register Custom Modules with Command Handler Source: https://context7.com/jamesconrad/discord-voice-normalizer/llms.txt Demonstrates how to register custom modules with the command handler in Node.js. This involves providing a module name, an array of commands with their handlers, and optional parameters for toggling the module and a unique bit ID. ```javascript const command = require('./modules/command'); const help = require('./modules/help'); function Initialize(client) { // Register module with commands // Parameters: moduleName, commandArray, toggleable, bitId let commands = [ { command: 'mycommand', callback: MyCommandHandler }, { command: 'another', callback: AnotherHandler } ]; command.RegisterModule("mymodule", commands, true, 5); // toggleable=true allows !toggle mymodule // bitId=5 is unique identifier (must be > 1, unique per module) // Add help page let page = { description: 'Module: MyModule', fields: [ { name: '!mycommand', value: 'Description of command', inline: true }, { name: '!another [args]', value: 'Another command', inline: true } ] }; help.AddPage('mymodule', page); } // Command handler signature async function MyCommandHandler(message, args) { // message - Discord.js Message object // args - Array of space-separated arguments after command return message.channel.send(`You said: ${args.join(' ')}`); } ``` -------------------------------- ### Display Interactive Help Menu Source: https://context7.com/jamesconrad/discord-voice-normalizer/llms.txt Displays an interactive help menu with all available commands, paginated and navigable using reaction buttons. The menu shows commands categorized by module. ```text User: !help Bot: [Embed] Conrad 2.0 Help Menu Page 1 / 5 Module: Help !help - Display this menu !cid - Display current channel id ... [React with: ◀️ ▶️ ⏪ ⏩ ❌] ``` -------------------------------- ### Display Current Server Command Prefix Source: https://context7.com/jamesconrad/discord-voice-normalizer/llms.txt Displays the current command prefix being used for the server. This command is useful for users to know which prefix to use for bot commands. ```text User: !prefix Bot: This server's prefix is: ! ``` -------------------------------- ### Database Schema Definition (SQLite) Source: https://context7.com/jamesconrad/discord-voice-normalizer/llms.txt Defines the schema for the SQLite database used for storing guild configurations and user scores. Includes tables for guilds, guild members, and users with foreign key relationships. ```sql CREATE TABLE guilds ( guild_id TEXT PRIMARY KEY, name TEXT, total_score INT, prefix TEXT, disabled_modules INT ); CREATE TABLE guild_members ( guild_id TEXT, user_id TEXT, FOREIGN KEY (guild_id) REFERENCES guilds(guild_id) ); CREATE TABLE users ( user_id TEXT PRIMARY KEY, name TEXT, score INT, monthlyScore INT, FOREIGN KEY (user_id) REFERENCES guild_members(user_id) ); ``` -------------------------------- ### Emote Importer Module Commands Source: https://context7.com/jamesconrad/discord-voice-normalizer/llms.txt Allows users to import emotes from FrankerFaceZ into their Discord server by providing emote names or IDs. Includes error handling for existing or non-existent emotes. ```text User: !addemote monkaS Bot: Emote successfully added: <:monkaS:123456789> # Multiple emotes: User: !addemote OMEGALUL Kappa 381875 Bot: The following were successfully added: <:OMEGALUL:123456790> <:Kappa:123456791> <:emoteName:123456792> # Error handling: User: !addemote existingEmote Bot: There is already an emote using that name: <:existingEmote:123456789> User: !addemote nonexistent_emote_xyz Bot: I could not find an emote called nonexistent_emote_xyz on FrankerFaceZ ``` -------------------------------- ### Enable or Disable Bot Modules per Server Source: https://context7.com/jamesconrad/discord-voice-normalizer/llms.txt Enables or disables specific bot modules for the current server. Requires Administrator permission. The bot confirms which modules were enabled or disabled and provides instructions on how to re-enable disabled modules. ```text User: !toggle trivia Bot: trivia has been disabled. User: !toggle trivia voice Bot: These modules have been enabled: trivia voice. # Attempting disabled command: User: !trivia Bot: This command is disabled. To enable, have an administrator type: !toggle trivia ``` -------------------------------- ### Voice Normalization Module Commands Source: https://context7.com/jamesconrad/discord-voice-normalizer/llms.txt Provides commands for the voice normalization module to join/leave voice channels, display current volumes, and calculate normalization settings. It uses RMS averaging for volume calculations. ```text User: !joinvoice Bot: *Joins voice channel and begins listening* # Console output: # Joined voice channel: ServerName -> ChannelName ``` ```text User: !leavevoice Bot: *Leaves voice channel* # Console output: # Leaving voice channel: ServerName -> ChannelName # Currently in 0 channels. ``` ```text User: !volume Bot: Listing perceived user volumes: Alice -> 65.32dB Bob -> 58.14dB Charlie -> 72.89dB ``` ```text User: !normalize Bot: Set the following people to the following volumes: Alice -> 100.00% (0.00dB) Bob -> 158.49% (+7.18dB) Charlie -> 63.10% (-7.57dB) # With arguments: User: !normalize 50 -a Bot: No valid volume passed, defaulting to 100% Set the following people to the following volumes: Alice -> 89.13% (-1.00dB) ... # Available arguments: # [number] - Target volume (0-200) # -a - Center around average volume instead of quietest # -i - Exclude yourself from calculations # -b - Include bots in normalization # -t - Add test users for demonstration # -h - Show help ``` -------------------------------- ### Display Current Channel ID Source: https://context7.com/jamesconrad/discord-voice-normalizer/llms.txt Displays the ID of the current channel where the command was invoked. This is a utility command for identifying channels. ```text User: !cid Bot: general id: 123456789012345678 ``` -------------------------------- ### Toggle Notifications for Invalid Commands Source: https://context7.com/jamesconrad/discord-voice-normalizer/llms.txt Toggles notifications for invalid commands. Requires Administrator permission. This command can be used to turn notifications on or off. ```text User: !nic Bot: Notifications on invalid commands has been turned off. User: !nic Bot: Notifications on invalid commands has been turned on. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.