Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating to Discord.js v12 #4

Merged
merged 1 commit into from
May 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions commands/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = {
const userLevel = userCollection.map(command => `**${command.name}** : ${command.description}`).join('\n');

//embeds
const ownerEmbed = new Discord.RichEmbed()
const ownerEmbed = new Discord.MessageEmbed()
.setColor(config.info_color)
.setTitle("Commands")
.setDescription(`Use \`${config.prefix}help [command name]\` to get information for each command.`)
Expand All @@ -34,34 +34,34 @@ module.exports = {
.addField("~ Moderator Level ~", moderatorLevel || "empty")
.addField("~ User level ~", userLevel || "empty")
.setThumbnail(client.user.avatarURL)
.setFooter(client.user.tag, client.user.avatarURL)
.setFooter(client.user.tag, client.user.avatarURL())
.setTimestamp();
const adminEmbed = new Discord.RichEmbed()
const adminEmbed = new Discord.MessageEmbed()
.setColor(config.info_color)
.setTitle("Command List")
.setDescription(`Use \`${config.prefix}help [command name]\` to get information for each command.`)
.addField("~ Admin Level ~", adminLevel || "empty")
.addField("~ Moderator Level ~", moderatorLevel || "empty")
.addField("~ User level ~", userLevel || "empty")
.setThumbnail(client.user.avatarURL)
.setFooter(client.user.tag, client.user.avatarURL)
.setFooter(client.user.tag, client.user.avatarURL())
.setTimestamp();
const moderatorEmbed = new Discord.RichEmbed()
const moderatorEmbed = new Discord.MessageEmbed()
.setColor(config.info_color)
.setTitle("Command List")
.setDescription(`Use \`${config.prefix}help [command name]\` to get information for each command.`)
.addField("~ Moderator Level ~", moderatorLevel || "empty")
.addField("~ User level ~", userLevel || "empty")
.setThumbnail(client.user.avatarURL)
.setFooter(client.user.tag, client.user.avatarURL)
.setFooter(client.user.tag, client.user.avatarURL())
.setTimestamp();
const userEmbed = new Discord.RichEmbed()
const userEmbed = new Discord.MessageEmbed()
.setColor(config.info_color)
.setTitle("Command List")
.setDescription(`Use \`${config.prefix}help [command name]\` to get information for each command.`)
.addField("~ User level ~", userLevel || "empty")
.setThumbnail(client.user.avatarURL)
.setFooter(client.user.tag, client.user.avatarURL)
.setFooter(client.user.tag, client.user.avatarURL())
.setTimestamp();

const noServerEmbed = getEmbed.execute(param, config.warning_color, "Configuration Needed", "\`mainServerID\` and/or \`threadServerID\` value is empty.");
Expand Down
2 changes: 1 addition & 1 deletion commands/guilds.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
const noServerEmbed = getEmbed.execute(param, config.warning_color, "Configuration Needed", "\`mainServerID\` and/or \`threadServerID\` value is empty.");
const noAdminEmbed = getEmbed.execute(param, config.warning_color, "Configuration Needed", "\`adminRoleID\`` value is empty.");
const noPermEmbed = getEmbed.execute(param, config.warning_color, "Missing Permission", "You don\'t have permission to run this command.");
const guildList = client.guilds.map(guild => `[**${guild.name}**] (\`${guild.id}\`)`).join("\n") || "This bot hasn't joined any guild yet.";
const guildList = client.guilds.cache.map(guild => `[**${guild.name}**] (\`${guild.id}\`)`).join("\n") || "This bot hasn't joined any guild yet.";
const listEmbed = getEmbed.execute(param, config.info_color, "Guilds", guildList);

if (message.author.id === config.botOwnerID) {
Expand Down
2 changes: 1 addition & 1 deletion commands/leave.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
const getEmbed = param.getEmbed;

const serverID = args.shift();
const getServer = client.guilds.get(serverID);
const getServer = client.guilds.cache.get(serverID);

const notFoundEmbed = getEmbed.execute(param, config.error_color, "Not Found", `Can\'t find guild with ID (\`${serverID}\`) in my collection.`);
const noPermEmbed = getEmbed.execute(param, config.warning_color, "Missing Permission", "You don\'t have permission to run this command.");
Expand Down
2 changes: 1 addition & 1 deletion commands/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
const notDMEmbed = getEmbed.execute(param, config.error_color, "Command Unavailable", "This command can only be used in Direct Message.")

if (message.guild != null && (message.guild.id == mainServerID || message.guild.id == threadServerID)) {
if(botChannelID != "empty" && message.channel.id == botChannelID){
if(botChannelID != "empty" && message.channel.id != botChannelID){
return;
} else {
return message.channel.send(notDMEmbed);
Expand Down
2 changes: 1 addition & 1 deletion commands/ping.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module.exports = {
let pingEmbed = getEmbed.execute(param, config.info_color, "Pong", "Ping?");

message.channel.send(pingEmbed).then((msg) => {
let editEmbed = getEmbed.execute(param, config.info_color, "Pong", `**Response time** : **${msg.createdTimestamp - message.createdTimestamp}** ms\n**API latency** : **${Math.round(param.client.ping)}** ms`);
let editEmbed = getEmbed.execute(param, config.info_color, "Pong", `**Response time** : **${msg.createdTimestamp - message.createdTimestamp}** ms\n**API latency** : **${Math.round(param.client.ws.ping)}** ms`);
msg.edit(editEmbed);
});
}
Expand Down
2 changes: 1 addition & 1 deletion commands/restart.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
const config = param.config;
const getEmbed = param.getEmbed;

const successEmbed = getEmbed.execute(param, config.info_color, "Restarting", `**Restarting in** : **${Math.round(param.client.ping)}** ms`);
const successEmbed = getEmbed.execute(param, config.info_color, "Restarting", `**Restarting in** : **${Math.round(param.client.ws.ping)}** ms`);
const noPermEmbed = getEmbed.execute(param, config.warning_color, "Missing Permission", "You don\'t have permission to run this command.");
const noServerEmbed = getEmbed.execute(param, config.warning_color, "Configuration Needed", "\`mainServerID\` and/or \`threadServerID\` value is empty.");
const noAdminEmbed = getEmbed.execute(param, config.warning_color, "Configuration Needed", "\`adminRoleID\` value is empty.");
Expand Down
22 changes: 11 additions & 11 deletions functions/aclose.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ module.exports = {
const ThreadDB = param.ThreadDB;

const mainServerID = config.mainServerID;
const mainServer = await client.guilds.get(mainServerID);
const mainServer = await client.guilds.cache.get(mainServerID);
const threadServerID = config.threadServerID;
const threadServer = await client.guilds.get(threadServerID);
const threadServer = await client.guilds.cache.get(threadServerID);
const categoryID = config.categoryID;
const logChannelID = config.logChannelID;
const logChannel = await threadServer.channels.get(logChannelID);
const logChannel = await threadServer.channels.cache.get(logChannelID);
const author = message.author;
const channel = message.channel;

Expand All @@ -28,33 +28,33 @@ module.exports = {
if (!isThread) {
return channel.send(noThreadEmbed);
} else {
const user = await client.users.get(isThread.userID);
const user = await client.users.cache.get(isThread.userID);
const logDescription = `${isThread.threadTitle}\n**Reason** : ${reason}\n**Note** : ${note}`;
const userDescription = `${isThread.threadTitle}\n**Reason** : ${reason}`;

var logEmbed;
const userDMEmbed = new Discord.RichEmbed()
const userDMEmbed = new Discord.MessageEmbed()
.setColor(config.warning_color)
.setAuthor("[Anonymous]")
.setTitle("Thread Closed")
.setDescription(userDescription)
.setFooter(mainServer.name, mainServer.avatarURL)
.setFooter(mainServer.name, mainServer.iconURL())
.setTimestamp();

if (user) {
logEmbed = new Discord.RichEmbed()
logEmbed = new Discord.MessageEmbed()
.setColor(config.warning_color)
.setAuthor(`[Anonymous] | ${author.tag}`, author.avatarURL)
.setAuthor(`[Anonymous] | ${author.tag}`, author.avatarURL())
.setTitle("Thread Closed")
.setDescription(logDescription)
.setFooter(`${user.tag} | ${user.id}`, user.avatarURL)
.setFooter(`${user.tag} | ${user.id}`, user.avatarURL())
.setTimestamp();
await user.send(userDMEmbed);
await logChannel.send(logEmbed);
} else {
logEmbed = new Discord.RichEmbed()
logEmbed = new Discord.MessageEmbed()
.setColor(config.warning_color)
.setAuthor(`[Anonymous] | ${author.tag}`, author.avatarURL)
.setAuthor(`[Anonymous] | ${author.tag}`, author.avatarURL())
.setTitle("Thread Closed")
.setDescription(logDescription)
.setFooter(`Can\'t find user | ${isThread.userID}`)
Expand Down
20 changes: 10 additions & 10 deletions functions/areply.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
name: "areply",
async execute(param, message, args){
const Discord = param.Discord;
const Attachment = param.Attachment;
const MessageAttachment = param.MessageAttachment;
const client = param.client;
const getEmbed = param.getEmbed;
const config = param.config;
Expand All @@ -11,9 +11,9 @@ module.exports = {
const isBlocked = param.isBlocked;

const mainServerID = config.mainServerID;
const mainServer = await client.guilds.get(mainServerID);
const mainServer = await client.guilds.cache.get(mainServerID);
const threadServerID = config.threadServerID;
const threadServer = await client.guilds.get(threadServerID);
const threadServer = await client.guilds.cache.get(threadServerID);
const categoryID = config.categoryID;
const author = message.author;
const channel = message.channel;
Expand All @@ -38,26 +38,26 @@ module.exports = {
return channel.send(blockedEmbed);
} else {
const userID = isThread.userID;
const member = await mainServer.members.get(userID);
const member = await mainServer.members.cache.get(userID);

if (!member) {
return channel.send(noUserEmbed);
} else {
const user = member.user;
const description = args.join(' ');
const userDMEmbed = new Discord.RichEmbed()
const userDMEmbed = new Discord.MessageEmbed()
.setColor(config.sent_color)
.setAuthor("[Anonymous]")
.setTitle("Message Received")
.setDescription(description)
.setFooter(mainServer.name, mainServer.avatarURL)
.setFooter(mainServer.name, mainServer.iconURL())
.setTimestamp();
const threadChannelEmbed = new Discord.RichEmbed()
const threadChannelEmbed = new Discord.MessageEmbed()
.setColor(config.sent_color)
.setAuthor(`[Anonymous] | ${author.tag}`, author.avatarURL)
.setAuthor(`[Anonymous] | ${author.tag}`, author.avatarURL())
.setTitle("Message Sent")
.setDescription(description)
.setFooter(`${user.tag} | ${user.id}`, user.avatarURL)
.setFooter(`${user.tag} | ${user.id}`, user.avatarURL())
.setTimestamp();

try{
Expand All @@ -70,7 +70,7 @@ module.exports = {
await channel.send(threadChannelEmbed);
if (message.attachments.size > 0) {
await message.attachments.forEach(async atch => {
let attachment = new Attachment(atch.url);
let attachment = new MessageAttachment(atch.url);
await user.send(attachment);
await channel.send(attachment);
});
Expand Down
6 changes: 3 additions & 3 deletions functions/bind.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ module.exports = {
const bind = param.bind;

const mainServerID = config.mainServerID;
const mainServer = await client.guilds.get(mainServerID);
const mainServer = await client.guilds.cache.get(mainServerID);
const threadServerID = config.threadServerID;
const threadServer = await client.guilds.get(threadServerID);
const threadServer = await client.guilds.cache.get(threadServerID);
const categoryID = config.categoryID;
const logChannelID = config.logChannelID;

const userID = args.shift();
const channelID = args.shift();
const isThread = await ThreadDB.findOne({where: {userID: userID}});
const isSame = await ThreadDB.findOne({where: {channelID: channelID}});
const getChannel = await threadServer.channels.get(channelID);
const getChannel = await threadServer.channels.cache.get(channelID);

const successEmbed = getEmbed.execute(param, config.info_color, "Success", `Binded <@${userID}> (\`${userID}\`) thread to <#${channelID}>.`);
const sameChannelEmbed = getEmbed.execute(param, config.error_color, "Failed", `Channel <#${channelID}> binded with a thread already.`);
Expand Down
24 changes: 12 additions & 12 deletions functions/close.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ module.exports = {
const ThreadDB = param.ThreadDB;

const mainServerID = config.mainServerID;
const mainServer = await client.guilds.get(mainServerID);
const mainServer = await client.guilds.cache.get(mainServerID);
const threadServerID = config.threadServerID;
const threadServer = await client.guilds.get(threadServerID);
const threadServer = await client.guilds.cache.get(threadServerID);
const categoryID = config.categoryID;
const logChannelID = config.logChannelID;
const logChannel = await threadServer.channels.get(logChannelID);
const logChannel = await threadServer.channels.cache.get(logChannelID);
const author = message.author;
const channel = message.channel;

Expand All @@ -28,33 +28,33 @@ module.exports = {
if (!isThread) {
return channel.send(noThreadEmbed);
} else {
const user = await client.users.get(isThread.userID);
const user = await client.users.cache.get(isThread.userID);
const logDescription = `${isThread.threadTitle}\n**Reason** : ${reason}\n**Note** : ${note}`;
const userDescription = `${isThread.threadTitle}\n**Reason** : ${reason}`;

var logEmbed;
const userDMEmbed = new Discord.RichEmbed()
const userDMEmbed = new Discord.MessageEmbed()
.setColor(config.warning_color)
.setAuthor(author.tag, author.avatarURL)
.setAuthor(author.tag, author.avatarURL())
.setTitle("Thread Closed")
.setDescription(userDescription)
.setFooter(mainServer.name, mainServer.avatarURL)
.setFooter(mainServer.name, mainServer.iconURL())
.setTimestamp();

if (user) {
logEmbed = new Discord.RichEmbed()
logEmbed = new Discord.MessageEmbed()
.setColor(config.warning_color)
.setAuthor(author.tag, author.avatarURL)
.setAuthor(author.tag, author.avatarURL())
.setTitle("Thread Closed")
.setDescription(logDescription)
.setFooter(`${user.tag} | ${user.id}`, user.avatarURL)
.setFooter(`${user.tag} | ${user.id}`, user.avatarURL())
.setTimestamp();
await user.send(userDMEmbed);
await logChannel.send(logEmbed);
} else {
logEmbed = new Discord.RichEmbed()
logEmbed = new Discord.MessageEmbed()
.setColor(config.warning_color)
.setAuthor(author.tag, author.avatarURL)
.setAuthor(author.tag, author.avatarURL())
.setTitle("Thread Closed")
.setDescription(logDescription)
.setFooter(`Can\'t find user | ${isThread.userID}`)
Expand Down
6 changes: 3 additions & 3 deletions functions/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ module.exports = {
}
};

const configEmbed = new Discord.RichEmbed()
const configEmbed = new Discord.MessageEmbed()
.setColor(config.info_color)
.setTitle("Configuration")
.addField("~ Bot ~", botConfig)
.addField("~ Server ~", serverConfig)
.addField("~ Embed Color ~", embedColorConfig)
.setThumbnail(client.user.avatarURL)
.setFooter(client.user.tag, client.user.avatarURL)
.setThumbnail(client.user.avatarURL())
.setFooter(client.user.tag, client.user.avatarURL())
.setTimestamp();
return configEmbed;
}
Expand Down
4 changes: 2 additions & 2 deletions functions/getEmbed.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module.exports = {
name: "getEmbed",
execute(param, color, title, description){
const embed = new param.Discord.RichEmbed()
const embed = new param.Discord.MessageEmbed()
.setColor(color)
.setTitle(title)
.setDescription(description)
.setFooter(param.client.user.tag, param.client.user.avatarURL)
.setFooter(param.client.user.tag, param.client.user.avatarURL())
.setTimestamp();
return embed;
}
Expand Down
4 changes: 2 additions & 2 deletions functions/isMember.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module.exports = {
async execute(param, userID){
const client = param.client;
const mainServerID = param.config.mainServerID;
const mainServer = await client.guilds.get(mainServerID);
const isMember = await mainServer.members.get(userID);
const mainServer = await client.guilds.cache.get(mainServerID);
const isMember = await mainServer.members.cache.get(userID);

if(isMember){
return true;
Expand Down
Loading