Skip to content

Commit

Permalink
Merge pull request #4 from Hab3925/master
Browse files Browse the repository at this point in the history
2
  • Loading branch information
MelodicAlbuild authored May 5, 2021
2 parents 97ca506 + 66eab0f commit 8112f0a
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 35 deletions.
12 changes: 12 additions & 0 deletions commands/moddingfaq.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports.run = async (client, message, args) => {
message.channel.send(`Check the <#831103119252520960> out! Your question is probably answered there. \nhttps://tenor.com/view/all-the-answers-mulder-book-xfiles-gif-11506981`,)
}
exports.help = {
name: "moddingfaq",
desc: "Refrence the <#831103119252520960> channel",
aliases: ["mfaq"],
permLvl: 0,
hidden: false,
category: "volc",
usage: "moddingfaq"
}
6 changes: 3 additions & 3 deletions commands/mute.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ module.exports.run = async (client, message, args) => {
time: args[1] * 3600000 + new Date().getTime()
})
client.mute.set(message.guild.id, obj)
message.channel.send(`Muted ${args[0]} for ${args[1]} hours.`)
client.channels.cache.get(client.logchn.get(message.guild.id)).send(`<@${message.author.id}> muted ${args[0]} for ${args[1]} hours.`)
message.channel.send(`Muted ${args[0]} for ${args[1]} hour(s).`)
client.channels.cache.get(client.logchn.get(message.guild.id)).send(`<@${message.author.id}> muted ${args[0]} for ${args[1]} hour(s).`)

//wait for timer to expire
setTimeout(() => {
Expand Down Expand Up @@ -88,4 +88,4 @@ exports.help = {
hidden: false,
category: "admin",
usage: "mute [@user] (hours)"
}
}
61 changes: 49 additions & 12 deletions commands/rankdesign.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,31 @@ module.exports.run = async (client, message, args, prefix, con, table) => {
const cardDisplay = await message.channel.send(client.rankembed1(user, rank));
const controllpanel = await message.channel.send(embed);

await controllpanel.react(arrowleft); await controllpanel.react(checkmark); await controllpanel.react(arrowright);
await controllpanel.react(arrowleft);
await controllpanel.react(checkmark);
await controllpanel.react(arrowright);

setTimeout(() => {
const collector = controllpanel.createReactionCollector(r => {
if (!r.users.cache.has(message.author.id)) return r.users.cache.forEach(u => { if (u.id !== client.user.id) r.users.remove(u); })

if (!r.users.cache.has(message.author.id)) return r.users.cache.forEach(u => {
if (u.id !== client.user.id) r.users.remove(u);
})
switch (r.emoji.id) {
case arrowleft.id:
r.users.cache.forEach(u => { if (u.id != client.user.id) { if (u.id !== client.user.id) r.users.remove(u); } });
if (cooldown.has(message.author.id)) return message.channel.send('You are reacting to rapidly!').then(msg => { msg.delete({ timeout: 5000 }) });
r.users.cache.forEach(u => {
if (u.id != client.user.id) {
if (u.id !== client.user.id) r.users.remove(u);
}
});
if (cooldown.has(message.author.id)) return message.channel.send('You are reacting to rapidly!').then(msg => {
msg.delete({
timeout: 5000
})
});
if (state[0] == 0) return;
state.push(state[0] - 1); state.shift();
state.push(state[0] - 1);
state.shift();
cardDisplay.edit(client.rankcard(user, rank, message.guild.id, state[0]))
cooldown.add(message.author.id)
setTimeout(() => {
Expand All @@ -46,23 +60,46 @@ module.exports.run = async (client, message, args, prefix, con, table) => {
break;

case checkmark.id:
r.users.cache.forEach(u => { if (u.id != client.user.id) { if (u.id !== client.user.id) r.users.remove(u); } });
if (cooldown.has(message.author.id)) return message.channel.send('You are reacting to rapidly!').then(msg => { msg.delete({ timeout: 5000 }) });
r.users.cache.forEach(u => {
if (u.id != client.user.id) {
if (u.id !== client.user.id) r.users.remove(u);
}
});
if (cooldown.has(message.author.id)) return message.channel.send('You are reacting to rapidly!').then(msg => {
msg.delete({
timeout: 5000
})
});
con.query(`UPDATE ${table} SET rankCard = ${state[0]} WHERE UserID = ${message.author.id}`);
if (state[0] == 0) cardname = '**Gears**'; else cardname = '**Lava**'
if (state[0] == 0) cardname = '**Gears**';
else cardname = '**Lava**'
message.reply(`Rankcard design changed to ${cardname}`);
collector.stop();
cardDisplay.delete({ timeout: 5000 }); controllpanel.delete({ timeout: 5000 })
cardDisplay.delete({
timeout: 5000
});
controllpanel.delete({
timeout: 5000
})
setTimeout(() => {
cooldown.delete(message.author.id)
}, cdseconds);
break;

case arrowright.id:
r.users.cache.forEach(u => { if (u.id != client.user.id) { if (u.id !== client.user.id) r.users.remove(u); } });
if (cooldown.has(message.author.id)) return message.channel.send('You are reacting to rapidly!').then(msg => { msg.delete({ timeout: 5000 }) });
r.users.cache.forEach(u => {
if (u.id != client.user.id) {
if (u.id !== client.user.id) r.users.remove(u);
}
});
if (cooldown.has(message.author.id)) return message.channel.send('You are reacting to rapidly!').then(msg => {
msg.delete({
timeout: 5000
})
});
if (state[0] == 1) return;
state.push(state[0] + 1); state.shift();
state.push(state[0] + 1);
state.shift();
cardDisplay.edit(client.rankcard(user, rank, message.guild.id, state[0]))
setTimeout(() => {
cooldown.delete(message.author.id)
Expand Down
2 changes: 1 addition & 1 deletion commands/say.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ exports.help = {
name: "say",
desc: "Make the captain say anything you would like.",
aliases: [],
permLvl: 3,
permLvl: 2,
hidden: false,
category: "dev",
usage: "say [message]"
Expand Down
7 changes: 6 additions & 1 deletion commands/test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
module.exports.run = async (client, message, args, prefix, con, table, permLvl, GSTable) => {

const filter = (reaction, user) => reaction.emoji.name === '👌' && user.id === '188762891137056769';
const collector = message.createReactionCollector(filter, {
time: 15000
});
collector.on('collect', r => console.log(`Collected ${r.emoji.name}`));
collector.on('end', collected => console.log(`Collected ${collected.size} items`));
}

exports.help = {
Expand Down
53 changes: 35 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ if (!loginToken) {
//require("./messageEvents/autoreply.js"); return; // Error to abort after printing/testing regex.

//constants
const Discord = require("discord.js");
const client = new Discord.Client({ ws: { intents: ['GUILD_MEMBERS'] } });
const Discord = require('discord.js');
const client = new Discord.Client({
ws: {
intents: ['GUILDS', 'GUILD_MESSAGES', 'GUILD_MEMBERS', 'GUILD_MESSAGE_REACTIONS']
}
});
const {
promisify
} = require("util");
Expand All @@ -34,6 +38,7 @@ let con = mysql.createConnection({
charset: "utf8mb4_unicode_ci"
});

//enmap setup
const Enmap = require("enmap");
client.commands = new Enmap();
client.aliases = new Enmap();
Expand Down Expand Up @@ -61,10 +66,7 @@ client.mute = new Enmap({
name: "mute"
})

client.on('guildMemberAdd', member => {
console.log("test")
});

//When client is ready ( on bot startup )
client.on("ready", async () => {
if (useDatabase) await client.connect(con);

Expand Down Expand Up @@ -118,19 +120,34 @@ client.on("ready", async () => {

});

//When user joins server that bot is in
client.on('guildMemberAdd', member => {
if (!client.mute.has(member.guild.id)) return
if (!client.mute.get(member.guild.id).role) return
let role = client.mute.get(member.guild.id).role
client.mute.get(member.guild.id).users.forEach(user => {
if (user == member.user.id) {
member.roles.add(role)
}
})
});

// When bot joins a guild/server
client.on("guildCreate", guild => {
let name = guild.name.replace(/'/g, `\\'`).replace(/"/g, `\\"`);
console.log(`| New Guild | ${guild.name} - ${guild.memberCount}`);
var query = `INSERT INTO ${GSTable} (guildID, roles, prefix, guildName, guildIcon, lockedChannels, members) VALUE ('${guild.id}', '[]','.','${name}','${guild.iconURL({ format: 'png', size: 2048 })}', '[]','${guild.memberCount}');`;
if (useDatabase) con.query(query);
});

// When bot leaves a guild/server
client.on("guildDelete", guild => {
console.log(`| Kicked | ${guild.name}`);
var query = `DELETE FROM ${GSTable} WHERE guildID='${guild.id}'`;
if (useDatabase) con.query(query);
});

//
require("./utility/functions.js")(client, useDatabase);
require("./utility/embeds.js")(client);
require("./utility/time.js")(client);
Expand Down Expand Up @@ -243,12 +260,12 @@ client.on("guildMemberUpdate", (oldMember, newMember) => {

client.on("userUpdate", (oldUser, newUser) => {
if (oldUser.avatarURL({
format: 'png',
size: 2048
}) !== newUser.avatarURL({
format: 'png',
size: 2048
}))
format: 'png',
size: 2048
}) !== newUser.avatarURL({
format: 'png',
size: 2048
}))
if (useDatabase) con.query(
`UPDATE ${table} SET profilePic = '${newUser.avatarURL({ format: 'png', size: 2048 })}' WHERE UserID = '${newUser.id}'`
);
Expand All @@ -257,12 +274,12 @@ client.on("userUpdate", (oldUser, newUser) => {
client.on("guildUpdate", (oldGuild, newGuild) => {
newGuild.name.replace(/'/g, `\\'`).replace(/"/g, `\\"`);
if (oldGuild.iconURL({
format: 'png',
size: 2048
}) !== newGuild.iconURL({
format: 'png',
size: 2048
}))
format: 'png',
size: 2048
}) !== newGuild.iconURL({
format: 'png',
size: 2048
}))
if (useDatabase) con.query(
`UPDATE ${GSTable} SET guildIcon = '${newGuild.iconURL({ format: 'png', size: 2048 })}' WHERE guildID = '${newGuild.id}'`
);
Expand Down

0 comments on commit 8112f0a

Please sign in to comment.