Skip to content

Commit

Permalink
🚀 v2.0 (Docs Soon)
Browse files Browse the repository at this point in the history
  • Loading branch information
HypnoticSiege committed Dec 28, 2021
1 parent d04240b commit 9795b0c
Show file tree
Hide file tree
Showing 25 changed files with 1,757 additions and 177 deletions.
76 changes: 76 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless

# FuseBox cache
.fusebox/
117 changes: 11 additions & 106 deletions bot.js
Original file line number Diff line number Diff line change
@@ -1,110 +1,15 @@
//Shared Dependancies
const config = require('./config');
const prefix = config.prefix;
const colors = require('colors/safe')

//Twitch Bot Dependancies
const tmi = require("tmi.js");

//Discord Bot Dependancies
const Discord = require('discord.js');
const Enmap = require("enmap");
const fs = require("fs");

const HypnoticDiscord = require('./discord')
HypnoticDiscord()

const HypnoticTwitch = require('./twitch')
HypnoticTwitch()

//Discord Bot Start
const client = new Discord.Client();
client.commands = new Enmap();

//Logging
client.on('messageDelete', async message => {
const log = client.channels.cache.get(config.DiscordLogs);
var embed = new Discord.MessageEmbed().setColor(`${config.embedColor}`).setAuthor('Message Deleted', message.guild.iconURL).addField('User', message.author.tag).addField('Message', message.content).addField('Channel', message.channel).setTimestamp()
if (message.author == client.user.id) return;
else return log.send(embed)
});

client.on("messageUpdate", function(oldMessage, newMessage) {
const log = client.channels.cache.get(config.DiscordLogs);
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 return log.send(embed)
});

//Event Handler
fs.readdir("./events/", (err, files) => {
if (err) return console.error(err);
files.forEach(file => {
const event = require(`./events/${file}`);
let eventName = file.split(".")[0];
client.on(eventName, event.bind(null, client));
console.log(colors.green(`${eventName} Event ✅`));
});
});
console.clear()
const figlet = require('figlet');
const colors = require('colors/safe')

//Command Handler
fs.readdir("./commands/", (err, files) => {
figlet(`Discord x Twitch`, function(err, data) {
if (err) return console.error(err);
files.forEach(file => {
if (!file.endsWith(".js")) return;
let props = require(`./commands/${file}`);
let commandName = file.split(".")[0];
console.log(colors.green(`${commandName} Command ✅`));
client.commands.set(commandName, props);
});
});
client.login(config.token);
//Discord Bot Finish



//Twitch Bot Start
const identityconfig = {
options: {
debug: true
},
connection: {
cluster: "aws",
reconnect: true
},
identity: {
username: config.username,
password: config.oauth
},
channels: config.channels
}

//Login/Connect Twitch
var twitchclient = new tmi.client(identityconfig)
twitchclient.connect();
twitchclient.on("connected", (address, port) => {
console.log(colors.green(`Twitch Bot Online ✅`))
})

//Set Logging Level
twitchclient.log.setLevel('warn')

//Main Function/Handler
twitchclient.on("chat", async(channel, user, message, self) => {
if (self) return;
const args = message.slice(prefix.length).trim().split(/ +/g);
const cmd = args.shift().toLowerCase();
//Command Handler
try {
let commandFile = require(`./twitch_cmds/${cmd}.js`)
commandFile.run(twitchclient, message, args, user, channel, self)
} catch (err) {}

//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();
return log.send(ChatEmbed)
})
//Twitch Bot End
console.log(colors.cyan(data));
console.log('Created by ' + colors.brightCyan(`HypnoticSiege - https://hypnoticsiege.net`))
});
42 changes: 29 additions & 13 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
module.exports = {
//Twitch Bot Configuration
username: 'hypnoticsiege',
//Get yours at https://twitchapps.com/tmi/
oauth: 'oauth:YOURTOKEN',
channels: ['hypnoticsiege'],
discord: {
token: "NzgxMTY0MjE4NjYxMzM5MTc2.X75p3w.GStgV70ZV98-lz5QTK7qBQbvJJo", //Get yours at https://discord.com/developers/applications/

//Discord Configuration
//Get yours at https://discord.com/developers/applications/
token: "YOUR_TOKEN_HERE",
DiscordLogs: "829169768703459338",
TwitchLogs: "829169768703459338",
logs: {
discord: {
enabled: true,
channel: '909654880669560902'
},

//Shared Configuration
prefix: '!',
embedColor: 'BLUE',
twitch: {
enabled: true,
channel: '924332370860052541'
}
},

embed: {
color: 'BLUE',
footer: 'Hypnotic Development',
logo: 'https://hypnoticsiege.net/images/uploads/logo.png'
}
},

twitch: {
oauth: 'oauth:1sy6feu1mdrs3mktj7b6vqvx5o9x9n', //Get yours at https://twitchapps.com/tmi/
channels: ['hypnoticsiege'],
username: 'hypnoticsiege'
},

shared: {
prefix: '!',
}
}
File renamed without changes.
File renamed without changes.
7 changes: 3 additions & 4 deletions events/channelCreate.js → discord/events/channelCreate.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
const Discord = require("discord.js");
const config = require("../config")

module.exports = (client, channel) => {
const log = client.channels.cache.get(config.DiscordLogs);
if (!log || !channel.guild) return
const log = client.channels.cache.get(client.config.discord.logs.discord.channel);

const embed = new Discord.MessageEmbed()
.setColor(`${config.embedColor}`)
.setColor(`${client.config.discord.embed.color}`)
.setAuthor('A channel was Created!')
.addField(`Channel Name:`, `${channel.name}`)
.addField(`Channel ID:`, `${channel.id}`)
Expand Down
6 changes: 3 additions & 3 deletions events/channelDelete.js → discord/events/channelDelete.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const Discord = require("discord.js");
const config = require("../config")

module.exports = (client, channel) => {
const log = client.channels.cache.get(config.DiscordLogs);
const log = client.channels.cache.get(client.config.discord.logs.discord.channel);
if (!log || !channel.guild) return

const embed = new Discord.MessageEmbed()
.setColor(`${config.embedColor}`)
.setColor(`${client.config.discord.embed.color}`)
.setAuthor('A channel was Deleted!')
.addField(`Channel Name:`, `${channel.name}`)
.addField(`Channel ID:`, `${channel.id}`)
Expand Down
6 changes: 3 additions & 3 deletions events/guildBanAdd.js → discord/events/guildBanAdd.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const Discord = require("discord.js");
const config = require("../config")

module.exports = (client, guild, user) => {
const log = client.channels.cache.get(config.DiscordLogs);
const log = client.channels.cache.get(client.config.discord.logs.discord.channel);
const embed = new Discord.MessageEmbed()
.setColor(`${config.embedColor}`)
.setColor(`${client.config.discord.embed.color}`)
.setAuthor('A new user was Banned!')
.addField(`Banned User:`, `${user.tag}`)
.addField(`User ID:`, `${user.id}`)
Expand Down
6 changes: 3 additions & 3 deletions events/guildBanRemove.js → discord/events/guildBanRemove.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const Discord = require("discord.js");
const config = require("../config")

module.exports = (client, guild, user) => {
const log = client.channels.cache.get(config.DiscordLogs);
const log = client.channels.cache.get(client.config.discord.logs.discord.channel);
const embed = new Discord.MessageEmbed()
.setColor(`${config.embedColor}`)
.setColor(`${client.config.discord.embed.color}`)
.setAuthor('A user was Unbanned!')
.addField(`Unbanned User:`, `${user.tag}`)
.addField(`User ID:`, `${user.id}`)
Expand Down
6 changes: 3 additions & 3 deletions events/guildMemberAdd.js → discord/events/guildMemberAdd.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const Discord = require("discord.js");
const config = require("../config")

module.exports = (client, member) => {
const log = client.channels.cache.get(config.DiscordLogs);
const log = client.channels.cache.get(client.config.discord.logs.discord.channel);
const embed = new Discord.MessageEmbed()
.setColor(`${config.embedColor}`)
.setColor(`${client.config.discord.embed.color}`)
.setAuthor('A new user Joined!')
.addField(`User Joined:`, `${member.user.tag}`)
.addField(`User ID:`, `${member.user.id}`)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const Discord = require("discord.js");
const config = require("../config")

module.exports = (client, member) => {
const log = client.channels.cache.get(config.DiscordLogs);
const log = client.channels.cache.get(client.config.discord.logs.discord.channel);
const embed = new Discord.MessageEmbed()
.setColor(`${config.embedColor}`)
.setColor(`${client.config.discord.embed.color}`)
.setAuthor('A uer Left!')
.addField(`User Left:`, `${member.user.tag}`)
.addField(`User ID:`, `${member.user.id}`)
Expand Down
5 changes: 2 additions & 3 deletions events/message.js → discord/events/message.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
module.exports = (client, message) => {
const config = require('../config')
if (message.author.bot) return;
if (message.content.indexOf(config.prefix) !== 0) return;
const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
if (message.content.indexOf(client.config.shared.prefix) !== 0) return;
const args = message.content.slice(client.config.shared.prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
const cmd = client.commands.get(command);
if (!cmd) return;
Expand Down
5 changes: 5 additions & 0 deletions discord/events/ready.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = async client => {
client.user.setActivity(client.config.twitch.channels[0], {
type: "WATCHING",
});
}
6 changes: 3 additions & 3 deletions events/roleCreate.js → discord/events/roleCreate.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const Discord = require("discord.js");
const config = require("../config")

module.exports = (client, role) => {
const log = client.channels.cache.get(config.DiscordLogs);
const log = client.channels.cache.get(client.config.discord.logs.discord.channel);
if (!log || !channel.guild) return

const embed = new Discord.MessageEmbed()
.setColor(`${config.embedColor}`)
.setColor(`${client.config.discord.embed.color}`)
.setAuthor('A new Role was Created!')
.addField(`Role Name:`, `${role.name}`)
.addField(`Role ID:`, `${role.id}`)
Expand Down
7 changes: 4 additions & 3 deletions events/roleDelete.js → discord/events/roleDelete.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const Discord = require("discord.js");
const config = require("../config")
const config = require("../../config")

module.exports = (client, role) => {
const log = client.channels.cache.get(config.DiscordLogs);
const log = client.channels.cache.get(client.config.discord.logs.discord.channel);
if (!log || !channel.guild) return

const embed = new Discord.MessageEmbed()
.setColor(`${config.embedColor}`)
.setColor(`${client.config.discord.embed.color}`)
.setAuthor('A Role was Deleted!')
.addField(`Role Name:`, `${role.name}`)
.addField(`Role ID:`, `${role.id}`)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
const parse = require('parse-duration')
const Discord = require("discord.js");
const config = require("../config");
const vcs = new Map()

module.exports = (client, oldState, newState) => {
const log = client.channels.cache.get(config.DiscordLogs);
const log = client.channels.cache.get(client.config.discord.logs.discord.channel);
if (!log) return
const embed = new Discord.MessageEmbed()
.setColor(`${config.embedColor}`)
.setColor(`${client.config.discord.embed.color}`)
.setAuthor('Voice Status Update!')
.setTimestamp()
if (oldState.serverDeaf !== newState.serverDeaf && newState.serverDeaf) log.send(embed.setDescription(`**${newState.member.user.tag}** Was Server Deafened!`))
Expand Down
Loading

0 comments on commit 9795b0c

Please sign in to comment.