Created
February 8, 2021 20:50
-
-
Save theimpossiblequiz/710a6d6dfdfc127212f46e6e3240366b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//INFORMATION: | |
// Made by Theimpossiblequiz#6969 | |
//Date started 11-21-2020 | |
//Used in server Pengwin Bois | |
//Last updated 11-25-2020 | |
//heart.js is the MAIN FILE for this bot. | |
const Discord = require('discord.js'); | |
const config = require('./config.json'); | |
const newUsers = new Discord.Collection(); | |
const client = new Discord.Client({ partials: ["MESSAGE", "CHANNEL", "REACTION" ]}); | |
const ytdl = require('ytdl-core'); | |
const fs = require('fs'); | |
const Welcome = require('discord-welcome'); | |
const memberCounter = require('./counters/member-counter'); | |
const queue = new Map() | |
client.commands = new Discord.Collection(); | |
client.events = new Discord.Collection(); | |
['command_handler', 'events_handler'].forEach(handler =>{ | |
require(`./handlers/${handler}`)(client, Discord); | |
}) | |
//Welcome Message code. | |
client.once('guildMemberAdd', (member) => { | |
const channelID ='703789549679280159'; | |
if(member.guild.id != '669902459204010004') return; | |
const embed = new Discord.MessageEmbed() | |
.setTitle(`Member Joined the Pengwin Bois Server!`) | |
.setDescription(`\`${member.user.tag}\` has joined the Pengwin Bois server! Please read the <#738589554847645797>. Enjoy your stay here! If you need support please use the command $ticket [reason]!`) | |
.setColor("RANDOM") | |
.setTimestamp() | |
.setFooter('Created by Lazysensy#1075 & theimpossiblequiz#6969', 'https://i.imgur.com/iGY5LBj.png'); | |
client.channels.cache.get(channelID).send(embed); | |
}); | |
client.on('guildBanAdd', async (guild, user, member) => { | |
const fetchedLogs = await guild.fetchAuditLogs({ | |
limit: 1, | |
type: 'MEMBER_BAN_ADD', | |
}); | |
// Since we only have 1 audit log entry in this collection, we can simply grab the first one | |
const banLog = fetchedLogs.entries.first(); | |
const channelLog = member.guild.channels.cache.find(channel => channel.name === "server-change-info-🌐"); | |
// Let's perform a coherence check here and make sure we got *something* | |
if (!banLog) return console.log(`${user.tag} was banned from ${guild.name} but no audit log could be found.`); | |
// We now grab the user object of the person who banned the user | |
// Let us also grab the target of this action to double check things | |
const { executor, target } = banLog; | |
// And now we can update our output with a bit more information | |
// We will also run a check to make sure the log we got was for the same kicked member | |
if (target.id === user.id) { | |
console.log(`${user.tag} got hit with the swift hammer of justice in the guild ${guild.name}, wielded by the mighty ${executor.tag}`); | |
} else { | |
channelLog.send(`${user.tag} got hit with the swift hammer of justice in the guild ${guild.name}, audit log fetch was inconclusive.`); | |
} | |
}); | |
//This is where the token for the bot is. DON NOT SHARE THIS CODE ANYWHERE. ALSO DO NOT CHANGE THIS! | |
client.login(config.token); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment