Codychat Addons (Extended ✧)
Some older addons (e.g., the YouTube embedder) throw deprecated warnings on PHP 8.1+. Check compatibility before buying.
The number one complaint about live chat is spam. The Pro Moderation addon scans every message for blacklisted URLs, excessive caps, or racial slurs. It can automatically:
// addons/custom-commands.jsclass CustomCommandsAddon constructor() this.commands = new Map(); this.prefix = '!'; this.permissions = new Map(); this.cooldowns = new Map();
// Register a new command registerCommand(config) const name, handler, permissions, cooldown, aliases = config; this.commands.set(name, handler, permissions: permissions ); // Register aliases aliases.forEach(alias => this.commands.set(alias, ['user'], cooldown: cooldown ); ); return this; // Execute command async executeCommand(commandName, user, args, chatRoom) const cmd = this.commands.get(commandName); if (!cmd) return false; // Check permissions if (!this.hasPermission(user, cmd.permissions)) this.sendMessage(chatRoom, `❌ $user.name, you don't have permission to use this command.`); return false; // Check cooldown if (this.isOnCooldown(user.id, commandName)) const remaining = this.getCooldownRemaining(user.id, commandName); this.sendMessage(chatRoom, `⏰ $user.name, please wait $remaining seconds before using this command again.`); return false; // Execute handler try await cmd.handler(user, args, chatRoom); this.setCooldown(user.id, commandName, cmd.cooldown); return true; catch (error) console.error(`Command error: $error`); this.sendMessage(chatRoom, `⚠️ Error executing command.`); return false; // Helper methods hasPermission(user, requiredPerms) isOnCooldown(userId, commandName) const key = `$userId:$commandName`; const cooldown = this.cooldowns.get(key); return cooldown && cooldown > Date.now(); setCooldown(userId, commandName, seconds) const key = `$userId:$commandName`; this.cooldowns.set(key, Date.now() + (seconds * 1000)); // Auto cleanup setTimeout(() => this.cooldowns.delete(key); , seconds * 1000); getCooldownRemaining(userId, commandName) const key = `$userId:$commandName`; const cooldown = this.cooldowns.get(key); return Math.ceil((cooldown - Date.now()) / 1000); sendMessage(chatRoom, message) // Integrate with CodyChat's send API if (window.CodyChat && window.CodyChat.sendMessage) window.CodyChat.sendMessage(chatRoom, message); // Parse message for commands parseMessage(message, user, chatRoom) if (!message.startsWith(this.prefix)) return false; const parts = message.slice(1).split(' '); const commandName = parts[0].toLowerCase(); const args = parts.slice(1); return this.executeCommand(commandName, user, args, chatRoom);// Example command implementations const commandsAddon = new CustomCommandsAddon(); codychat addons
// !ping command commandsAddon.registerCommand( name: 'ping', handler: (user, args, chatRoom) => commandsAddon.sendMessage(chatRoom,
🏓 Pong! $user.name); , permissions: ['user'], cooldown: 3, aliases: ['p'] );// !time command commandsAddon.registerCommand( name: 'time', handler: (user, args, chatRoom) => const now = new Date(); const timeStr = now.toLocaleTimeString(); commandsAddon.sendMessage(chatRoom,
🕐 Current time: $timeStr); , permissions: ['user'], cooldown: 5 );
// !kick command (mod only) commandsAddon.registerCommand( name: 'kick', handler: async (user, args, chatRoom) => 'No reason provided'; // Integrate with CodyChat kick API if (window.CodyChat && window.CodyChat.kickUser) window.CodyChat.kickUser(chatRoom, targetName, reason); commandsAddon.sendMessage(chatRoom, `👢 $targetName was kicked by $user.name. Reason: $reason`); , permissions: ['mod', 'admin', 'owner'], cooldown: 10
);
// !poll command
commandsAddon.registerCommand({
name: 'poll',
handler: (user, args, chatRoom) => {
const question = args.join(' ');
if (!question)
commandsAddon.sendMessage(chatRoom, ⚠️ Usage: !poll <question>);
return;
const pollId = Date.now();
commandsAddon.sendMessage(chatRoom, `📊 POLL: $question`);
commandsAddon.sendMessage(chatRoom, `✅ Type "!yes $pollId" to vote yes`);
commandsAddon.sendMessage(chatRoom, `❌ Type "!no $pollId" to vote no`);
// Store poll data
if (!window.activePolls) window.activePolls = {};
window.activePolls[pollId] =
question,
creator: user.name,
votes: yes: [], no: [] ,
active: true
;
},
permissions: ['user'],
cooldown: 30
});
// Initialize addon function initCustomCommands() // Hook into CodyChat's message handler if (window.CodyChat && window.CodyChat.onMessage) window.CodyChat.onMessage((message, user, room) => commandsAddon.parseMessage(message, user, room); );
console.log('✅ Custom Commands Addon loaded!');
// Export for use if (typeof module !== 'undefined' && module.exports) module.exports = CustomCommandsAddon, commandsAddon, initCustomCommands ;
Add a modular command system that allows users to create custom chat commands with actions, responses, and permissions.
Stock CodyChat tells users "We are offline." This addon changes that. When no operators are active, it captures the user's name, email, and question, saves it to a CSV file, and sends an email alert to the support team.
