Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function main() {
try {
// Inicia o servidor
const Server = server();
// Inicializa a API da Twitch e do Giphy
const { channels, token, username } = config.twitch;
const { token: giphy_token, rating } = config.giphy;
const { chat } = new twitch({ token, username });
const gif = giphy(giphy_token);
// Conecta na Twitch e aos entra nos chats configurados
await chat.connect();
await Promise.all(channels.map(ch => chat.join(ch)));
// Escutar todas as mensagem privadas
chat.on('PRIVMSG', async payload => {
const {
tags: { color },
username,
message,
channel,
} = payload;
// Caso o usuário não tem uma cor definida, ele irá gerar uma cor
const user_color = color === true ? GenerateColor() : color;
return new Promise((resolve, reject) => {
if (state) {
return resolve(state)
}
let word = getRandomWord()
return resolve(giphy().search(word).then(res => ({
word,
url: res.data[0].images.fixed_height.url,
tries: -1
})))
})
}