This commit is contained in:
Sarimoko 2022-02-14 15:52:11 -08:00
parent 315b11fa41
commit e138f0eecf
1 changed files with 74 additions and 76 deletions

View File

@ -17,6 +17,8 @@ const client = new tmi.Client({
channels: [ process.env.TTV_CHANNELS ] channels: [ process.env.TTV_CHANNELS ]
}); });
client.connect();
// RNG User // RNG User
const rp = require('request-promise'); // For RNG const rp = require('request-promise'); // For RNG
function getChatters(channelName, _attemptCount = 0) { function getChatters(channelName, _attemptCount = 0) {
@ -60,10 +62,36 @@ const client = new tmi.Client({
chatters[Math.floor(Math.random() * chatters.length)]; chatters[Math.floor(Math.random() * chatters.length)];
}); });
} }
client.on('message', (channel, tags, message, self) => {
if(self) return;
const badges = tags.badges || {}; // Scan Badges
const isBroadcaster = badges.broadcaster; // Define Streamer
const isMod = badges.moderator; // Define Mod
const isModUp = isBroadcaster || isMod; // Permission Merge = Mod+Streamer
const isSub = badges.subscriber || badges.founder; // Define Subs
const botUserState = client.userstate[channel]; // MOD Status Check
const amMod = botUserState !== undefined && botUserState.mod === true; // Define Mod Status
if(self || !message.startsWith('!')) return; // Command Parser
const args = message.slice(1).split(' ');
const command = args.shift().toLowerCase(); // !COMMAND => command
if(command === 'rnguser') {
// Get a random user but skip the user requesting a random user
getRandomChatter(channel, { skipList: [ tags.username ] })
.then(user => {
if(user === null) {
client.say(channel, `Sorry ${tags.username}, this is embarrassing... There was no one to choose from! #smallstreamerproblems Bleep-Bloop!`);
}
else {
let { name, type } = user;
client.say(channel, `${tags.username} exluded, at random I choose "${name}" cuz they're such an amazing ${type}!`);
}
})
.catch(err => console.log('[ERR]', err));
} }
client.connect(); });
// ALERTS START // ALERTS START
// ================================ // ================================
// -------------------------------- // --------------------------------
@ -335,33 +363,3 @@ client.on("whisper", (from, userstate, message, self) => {
}); });
// ALERTS STOP // ALERTS STOP
// ================================ // ================================
client.on('message', (channel, tags, message, self) => {
if(self) return;
const badges = tags.badges || {}; // Scan Badges
const isBroadcaster = badges.broadcaster; // Define Streamer
const isMod = badges.moderator; // Define Mod
const isModUp = isBroadcaster || isMod; // Permission Merge = Mod+Streamer
const isSub = badges.subscriber || badges.founder; // Define Subs
const botUserState = client.userstate[channel]; // MOD Status Check
const amMod = botUserState !== undefined && botUserState.mod === true; // Define Mod Status
if(self || !message.startsWith('!')) return; // Command Parser
const args = message.slice(1).split(' ');
const command = args.shift().toLowerCase(); // !COMMAND => command
if(command === 'rnguser') {
// Get a random user but skip the user requesting a random user
getRandomChatter(channel, { skipList: [ tags.username ] })
.then(user => {
if(user === null) {
client.say(channel, `Sorry ${tags.username}, this is embarrassing... There was no one to choose from! #smallstreamerproblems Bleep-Bloop!`);
}
else {
let { name, type } = user;
client.say(channel, `${tags.username} exluded, at random I choose "${name}" cuz they're such an amazing ${type}!`);
}
})
.catch(err => console.log('[ERR]', err));
}
});