MCPcopy Create free account
hub / github.com/Xchristech2/Zenitsu-Bot / animeCommand

Function animeCommand

commands/anime.js:118–149  ·  view source on GitHub ↗
(sock, chatId, message, args)

Source from the content-addressed store, hash-verified

116}
117
118async function animeCommand(sock, chatId, message, args) {
119 const subArg = args && args[0] ? args[0] : '';
120 const sub = normalizeType(subArg);
121
122 const supported = [
123 'nom', 'poke', 'cry', 'kiss', 'pat', 'hug', 'wink', 'face-palm', 'quote'
124 ];
125
126 try {
127 if (!sub) {
128 // Fetch supported types from API for dynamic help
129 try {
130 const res = await axios.get(ANIMU_BASE);
131 const apiTypes = res.data && res.data.types ? res.data.types.map(s => s.replace('/animu/', '')).join(', ') : supported.join(', ');
132 await sock.sendMessage(chatId, { text: `Usage: .animu <type>\nTypes: ${apiTypes}` }, { quoted: message });
133 } catch {
134 await sock.sendMessage(chatId, { text: `Usage: .animu <type>\nTypes: ${supported.join(', ')}` }, { quoted: message });
135 }
136 return;
137 }
138
139 if (!supported.includes(sub)) {
140 await sock.sendMessage(chatId, { text: `❌ Unsupported type: ${sub}. Try one of: ${supported.join(', ')}` }, { quoted: message });
141 return;
142 }
143
144 await sendAnimu(sock, chatId, message, sub);
145 } catch (err) {
146 console.error('Error in animu command:', err);
147 await sock.sendMessage(chatId, { text: '❌ An error occurred while fetching animu.' }, { quoted: message });
148 }
149}
150
151module.exports = { animeCommand };
152

Callers

nothing calls this directly

Calls 2

normalizeTypeFunction · 0.85
sendAnimuFunction · 0.85

Tested by

no test coverage detected