Skip to content

Commit

Permalink
🐛 No More Webhook/New Logging
Browse files Browse the repository at this point in the history
No more Webhook Node, just straight from the bot!
  • Loading branch information
HypnoticSiege committed May 25, 2021
1 parent 6fd517f commit b5de8be
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 64 deletions.
15 changes: 9 additions & 6 deletions bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ const colors = require('colors/safe')

//Twitch Bot Dependancies
const tmi = require("tmi.js");
const { Webhook, MessageBuilder } = require('discord-webhook-node');
const hook = new Webhook(config.webhookURL);

//Discord Bot Dependancies
const Discord = require('discord.js');
Expand All @@ -25,11 +23,13 @@ client.on('messageDelete', async message => {
if (message.author == client.user.id) return;
else client.channels.cache.get(config.channelLogs).send(embed);
});

client.on("messageUpdate", function(oldMessage, newMessage) {
var embed = new Discord.MessageEmbed().setColor(`${config.embedColor}`).setAuthor(`Message Edited`).setDescription(`**User:** \n${oldMessage.author.tag}\n\n**Old Message:** \n${oldMessage.content}\n\n**New Message:** \n${newMessage.content}`).addField('Channel', `${oldMessage.channel}`).setTimestamp()
if (oldMessage.author == client.user.id) return;
else client.channels.cache.get(config.channelLogs).send(embed);
});

//Event Handler
fs.readdir("./events/", (err, files) => {
if (err) return console.error(err);
Expand All @@ -40,6 +40,7 @@ fs.readdir("./events/", (err, files) => {
console.log(colors.green(`${eventName} Event ✅`));
});
});

//Command Handler
fs.readdir("./commands/", (err, files) => {
if (err) return console.error(err);
Expand Down Expand Up @@ -92,14 +93,16 @@ twitchclient.on("chat", async(channel, user, message, self) => {
let commandFile = require(`./twitch_cmds/${cmd}.js`)
commandFile.run(twitchclient, message, args, user, channel, self)
} catch (err) {}
//Webhook Sender
const embed = new MessageBuilder()

//Chat Logger
const log = client.channels.cache.get(config.TwitchLogs);
const ChatEmbed = new Discord.MessageEmbed()
.setAuthor(`Message Sent by ${user.username}`)
.setTitle(`New Message on ${channel}'s Channel`)
.addField('Message Content:', `${message}`)
.setFooter('Message Sent')
.setColor(config.embedColor)
.setTimestamp();
hook.setUsername(`Twitch Logs for ${channel}`);
hook.send(embed);
return log.send(ChatEmbed)
})
//Twitch Bot End
9 changes: 3 additions & 6 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ module.exports = {
//Discord Configuration
//Get yours at https://discord.com/developers/applications/
token: "YOUR_TOKEN_HERE",
channelLogs: "829169768703459338",
memberLogs: "829169768703459338",
serverLogs: "829169768703459338",
voiceLogs: "829169768703459338",
DiscordLogs: "829169768703459338",
TwitchLogs: "829169768703459338",

//Shared Configuration
prefix: '!',
webhookURL: 'https://discord.com/api/webhooks/846482942770544641/m56T-YwM8RWPFJaQvs0c6dD9-nDPgXfVZx_BodaMAjKTyg9h-hIKigR0bsqUlekIknS7',
webhookColor: 'BLUE'
embedColor: 'BLUE',
}
2 changes: 1 addition & 1 deletion events/channelCreate.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const Discord = require("discord.js");
const config = require("../config")
module.exports = (client, channel) => {
const log = client.channels.cache.get(config.channelLogs);
const log = client.channels.cache.get(config.DiscordLogs);
if (!log || !channel.guild) return

const embed = new Discord.MessageEmbed()
Expand Down
2 changes: 1 addition & 1 deletion events/channelDelete.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const Discord = require("discord.js");
const config = require("../config")
module.exports = (client, channel) => {
const log = client.channels.cache.get(config.channelLogs);
const log = client.channels.cache.get(config.DiscordLogs);
if (!log || !channel.guild) return

const embed = new Discord.MessageEmbed()
Expand Down
2 changes: 1 addition & 1 deletion events/guildBanAdd.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const Discord = require("discord.js");
const config = require("../config")
module.exports = (client, guild, user) => {
const log = client.channels.cache.get(config.serverLogs);
const log = client.channels.cache.get(config.DiscordLogs);
const embed = new Discord.MessageEmbed()
.setColor(`${config.embedColor}`)
.setAuthor('A new user was Banned!')
Expand Down
2 changes: 1 addition & 1 deletion events/guildBanRemove.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const Discord = require("discord.js");
const config = require("../config")
module.exports = (client, guild, user) => {
const log = client.channels.cache.get(config.serverLogs);
const log = client.channels.cache.get(config.DiscordLogs);
const embed = new Discord.MessageEmbed()
.setColor(`${config.embedColor}`)
.setAuthor('A user was Unbanned!')
Expand Down
2 changes: 1 addition & 1 deletion events/guildMemberAdd.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const Discord = require("discord.js");
const config = require("../config")
module.exports = (client, member) => {
const log = client.channels.cache.get(config.memberLogs);
const log = client.channels.cache.get(config.DiscordLogs);
const embed = new Discord.MessageEmbed()
.setColor(`${config.embedColor}`)
.setAuthor('A new user Joined!')
Expand Down
2 changes: 1 addition & 1 deletion events/guildMemberRemove.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const Discord = require("discord.js");
const config = require("../config")
module.exports = (client, member) => {
const log = client.channels.cache.get(config.memberLogs);
const log = client.channels.cache.get(config.DiscordLogs);
const embed = new Discord.MessageEmbed()
.setColor(`${config.embedColor}`)
.setAuthor('A uer Left!')
Expand Down
2 changes: 1 addition & 1 deletion events/roleCreate.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const Discord = require("discord.js");
const config = require("../config")
module.exports = (client, role) => {
const log = client.channels.cache.get(config.serverLogs);
const log = client.channels.cache.get(config.DiscordLogs);
if (!log || !channel.guild) return

const embed = new Discord.MessageEmbed()
Expand Down
2 changes: 1 addition & 1 deletion events/roleDelete.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const Discord = require("discord.js");
const config = require("../config")
module.exports = (client, role) => {
const log = client.channels.cache.get(config.serverLogs);
const log = client.channels.cache.get(config.DiscordLogs);
if (!log || !channel.guild) return

const embed = new Discord.MessageEmbed()
Expand Down
2 changes: 1 addition & 1 deletion events/voiceStateUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const config = require("../config");
const vcs = new Map()

module.exports = (client, oldState, newState) => {
const log = client.channels.cache.get(config.voiceLogs);
const log = client.channels.cache.get(config.DiscordLogs);
if (!log) return
const embed = new Discord.MessageEmbed()
.setColor(`${config.embedColor}`)
Expand Down
47 changes: 10 additions & 37 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 12 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
{
"name": "hypnoticbot",
"name": "twitch-x-discord",
"version": "1.0.0",
"description": "",
"description": "A Multi-Bot using Discord.js and tmi.js to enhance logging, and streamers needs!",
"main": "bot.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "me",
"repository": {
"type": "git",
"url": "git+https://github.com/HypnoticSiege/Discord-x-Twitch.git"
},
"author": "HypnoticSiege",
"license": "ISC",
"bugs": {
"url": "https://github.com/HypnoticSiege/Discord-x-Twitch/issues"
},
"homepage": "https://github.com/HypnoticSiege/Discord-x-Twitch#readme",
"dependencies": {
"colors": "^1.4.0",
"discord-webhook-node": "^1.1.8",
"discord.js": "^12.5.3",
"enmap": "^5.8.5",
"fs": "0.0.1-security",
"parse-duration": "^1.0.0",
"tmi.js": "^1.8.3",
"twitch-bot": "^1.3.5"
"tmi.js": "^1.8.3"
}
}

0 comments on commit b5de8be

Please sign in to comment.