Skip to content

Commit

Permalink
Merge pull request #14 from Ezzud/v1.4.3
Browse files Browse the repository at this point in the history
1.4.3 BETA
  • Loading branch information
Ezzud authored Sep 17, 2021
2 parents 63ee15b + 36dd53f commit be539c0
Show file tree
Hide file tree
Showing 23 changed files with 764 additions and 502 deletions.
286 changes: 154 additions & 132 deletions commands/create.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions commands/help.js

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

26 changes: 18 additions & 8 deletions commands/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const moment = require('moment');
const fs = require('fs');
const Topgg = require(`@top-gg/sdk`)
const config = require('../config.json')
const QuickChart = require('quickchart-js');
var api;
if (config.topggEnabled === true) {
api = new Topgg.Api(config.topggToken)
Expand Down Expand Up @@ -54,10 +55,7 @@ module.exports.run = async (client, pf, message, args, manager,json,lang) => {
hours = roundTowardsZero(remainingTime / 3600000) % 24,
minutes = roundTowardsZero(remainingTime / 60000) % 60,
seconds = roundTowardsZero(remainingTime / 1000) % 60;
let d;
let h;
let m;
let s;
let d,h,m,s;
if(days > 0) {
d = `${days} ${lang.infoDays}`
} else if(days === 0) {
Expand Down Expand Up @@ -102,21 +100,33 @@ module.exports.run = async (client, pf, message, args, manager,json,lang) => {
if (config.topggEnabled === true) {
votes = await api.getVotes()
}

const pingChart = new QuickChart();
await pingChart.setConfig({
type: 'bar',
data: { labels: ['1m ago',"45s ago","30s ago",'15s ago', 'Now'], datasets: [{ label: 'Average API ping', data: client.pinglist }] },
});
pingChart.setWidth(400).setHeight(200).setBackgroundColor('transparent');


var chart = await pingChart.getShortUrl();

var embed = new Discord.MessageEmbed()
.setTitle(lang.infoTitle)
.setColor('#e4b400')
.setColor('#F5E351')
.setThumbnail(client.user.avatarURL())
.addField(lang.infoPingTitle.split("%loading%").join(loadings), `${lang.infoPingField.split("%messagePing%").join(messagePing).split("%apiPing%").join(apiPing)}`, true)
.addField(lang.infoShardsTitle.split("%shard%").join(getEmoji("sharding")), `${lang.infoShardsField.split("%activeShards%").join(count3).split("%maxShards%").join(client.shard.count).split("%shard%").join(client.shard.ids[0])}`, true)
.addField(lang.infoShardsTitle.split("%shard%").join(getEmoji("sharding")), `${lang.infoShardsField.split("%activeShards%").join(count3).split("%maxShards%").join(client.shard.count).split("%shard%").join(client.shard.ids[0])}`, false)
.addField(lang.infoUptimeTitle.split("%uptime%").join(getEmoji("computer")), `${lang.infoUptimeField.split("%uptime%").join(msg)}`, false);
if (config.topggEnabled === true) {
embed.addField(lang.infoVotesTitle.split("%vote%").join(":inbox_tray:"), `${lang.infoVotesField.split("%votes%").join(votes.length)}`, true)
}
embed.addField(lang.infoMemoryTitle.split("%memory%").join(getEmoji("memoire")), `${lang.infoMemoryField.split("%memory%").join(bts(memory.heapUsed))}`, true)
.addField(lang.infoDevTitle.split("%dev%").join(getEmoji("dev")), `${lang.infoDevField}`, true)
.addField(lang.infoServersTitle, `${lang.infoServersField.split("%servers%").join(req)}`, false)
.addField(lang.infoChangelogTitle, `${lang.infoChangelogField.split("%version%").join(json.version).split("%changelogs%").join(json.changelog)}`, false)
.addField(lang.infoChangelogTitle, `${lang.infoChangelogField.split("%version%").join(json.version).split("%changelogs%").join(`[Github](https://github.com/Ezzud/tadaa) - [Website](https://ezzud.fr)`)}`, false)
.addField(lang.infoServersTitle, `${lang.infoServersField.split("%servers%").join(req)}`, true)
.addField(`\u200B`, lang.infoSupportField)
.setImage(chart)
.setFooter(lang.footer.split("%version%").join(json.version), message.author.avatarURL());

await message.channel.send(embed)
Expand Down
94 changes: 47 additions & 47 deletions commands/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var util = require('util');
const log_stdout = process.stdout;
var path = require('path');
var commandname = path.basename(__filename);
const loadings = `<a:erjbgtuezrftetgfret:688433071573565440>`

module.exports.run = async (client, pf, message, args, manager,json,lang) => {
console.log = function(d) {
Expand All @@ -23,64 +24,63 @@ console.log = function(d) {
return;
}
}

let permembed = new Discord.MessageEmbed().setColor('E93C21').setAuthor(message.author.tag, message.author.avatarURL(), `https://github.com/Ezzud/tadaa`).setDescription(lang.GWNoBotPermission.split("%nope%").join(client.nope)).setFooter(lang.footer.split("%version%").join(json.version))
if (!message.guild.member(client.user).hasPermission(379968)) return (message.channel.send(permembed));

var embed = new Discord.MessageEmbed()
.setAuthor(lang.listEmbedTitle, client.user.avatarURL())
.setColor(`#F79430`)
.addField(`\u200B`, `${loadings} Loading active giveaways...`)
.addField(lang.listEmbedInfoTitle, lang.listEmbedInfoField)
.setFooter(lang.footer.split("%version%").join(json.version), message.author.avatarURL())
.setTimestamp()
let mm = await message.channel.send(embed)
let onServer;
onServer = client.giveawaysManager.giveaways.filter((g) => g.guildID === message.guild.id);
onServer = onServer.filter((g) => g.ended !== true);
let onServer2;
let onServer3;
let onServer4;
if (!onServer) {
onServer = 'Aucun :('
} else {
onServer = onServer.map(g => `${lang.listGiveawaysMap.split("%prize%").join(g.prize).split("%endDate%").join(`${moment(new Date(g.endAt).setHours(new Date(g.endAt).getHours() + 1)).format('L')} ${moment(new Date(g.endAt).setHours(new Date(g.endAt).getHours() + 1)).format('LT')}`).split("%endAt%").join(moment(g.endAt).fromNow())} [${lang.listGiveawaysAccessButton}](https://discordapp.com/channels/${g.guildID}/${g.channelID}/${g.messageID})::`)
onServer = Array.from(onServer)
if (onServer[6] !== undefined && onServer[10] !== undefined) {
onServer2 = onServer.slice(6, 10)
onServer2 = onServer2.toString().replace(/::/g, `\n`).replace(/,/g, ``)
} else {
onServer2 = `\u200B`;
}
if (onServer[11] !== undefined && onServer[15] !== undefined) {
onServer3 = onServer.slice(11, 15)
onServer3 = onServer3.toString().replace(/::/g, `\n`).replace(/,/g, ``)
} else {
onServer3 = `\u200B`;
var list = [""]
var firstvalue = 0
var i = 0
for(i in onServer) {
if(list[firstvalue].length >= 900) {
list[firstvalue + 1] = ""
var giveaway = onServer[i];
var formatedDate = giveaway.endAt.toString();
formatedDate = formatedDate.substring(0, formatedDate.length - 3)
formatedDate = parseInt(formatedDate)
var msg = `:gift: ${giveaway.prize} - <t:${formatedDate}> (<t:${formatedDate}:R>) - <#${giveaway.channelID}>`
list[firstvalue + 1] = `${list[firstvalue + 1]}${msg}\n`
firstvalue++
i++
} else {
var giveaway = onServer[i];
var formatedDate = giveaway.endAt.toString();
formatedDate = formatedDate.substring(0, formatedDate.length - 3)
formatedDate = parseInt(formatedDate)
var msg = `:gift: ${giveaway.prize} - <t:${formatedDate}> (<t:${formatedDate}:R>) - <#${giveaway.channelID}>`
list[firstvalue] = `${list[firstvalue]}${msg}\n`
i++
}

}
if (onServer[16] !== undefined && onServer[20] !== undefined) {
onServer4 = onServer.slice(16, 20)
onServer4 = onServer4.toString().replace(/::/g, `\n`).replace(/,/g, ``)
var embed = new Discord.MessageEmbed()
.setAuthor(lang.listEmbedTitle, client.user.avatarURL())
.setColor(`#2ADAEF`)
var listing = 0;
for(listing in list) {
if(listing === 0) {
embed.addField(`\u200B`, list[listing] || listEmbedNoGiveaway);
} else {
onServer4 = `\u200B`;
embed.addField(`\u200B`, list[listing] || `\u200B`);
}
onServer = onServer.slice(0, 5)
onServer = onServer.toString().replace(/::/g, `\n`).replace(/,/g, ``)
}
if (onServer.lenght > 1000) {
onServer = 'Aucun :('
}
if (onServer2.lenght > 1000) {
onServer2 = `\u200B`
}
if (onServer3.lenght > 1000) {
onServer3 = `\u200B`

listing++;
}
if (onServer4.lenght > 1000) {
onServer4 = `\u200B`
}
var embed = new Discord.MessageEmbed()
.setAuthor(lang.listEmbedTitle)
.setThumbnail(client.user.avatarURL())
.setColor(`#F79430`)
.addField(`\u200B`, onServer || lang.listEmbedNoGiveaway)
.addField(`\u200B`, `${onServer2 || `\u200B`}`)
.addField(`\u200B`, `${onServer3 || `\u200B`}`)
.addField(`\u200B`, `${onServer4 || `\u200B`}\n\n\u200B`)
.addField(lang.listEmbedInfoTitle, lang.listEmbedInfoField)
embed.addField(lang.listEmbedInfoTitle, lang.listEmbedInfoField)
.setFooter(lang.footer.split("%version%").join(json.version), message.author.avatarURL())
.setTimestamp()
message.channel.send(embed)
await mm.edit(embed)
}
module.exports.help = {
name: "list"
Expand Down
32 changes: 6 additions & 26 deletions commands/ping.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,19 @@
'use strict';
const Discord = require("discord.js");
const moment = require('moment');
const fs = require('fs')
var util = require('util');
const log_stdout = process.stdout;
var path = require('path');
var commandname = path.basename(__filename);

module.exports.run = async (client, pf, message, args, manager, json, lang) => {
console.log = function(d) {
let date = new Date();
date.setHours(date.getHours() + 2); //
fs.appendFileSync(`${client.logs_path}`, `\n(${commandname}) ${moment(date).format('MM-D-YYYY hh:mm')} | ${d}`, "UTF-8", {
'flags': 'a+'
});
log_stdout.write(`SHARD #${client.shard.ids[0]} ` + util.format(d) + '\n');
};
var messagePing = new Date().getTime() - message.createdTimestamp
var apiPing = Math.trunc(client.ws.ping)
let color;
if (apiPing + messagePing > 800) {
color = ':red_circle: '
} else if (apiPing + messagePing > 400) {
color = ':orange_circle: '
if (apiPing + messagePing > 500) {
color = client.dnd
} else if (apiPing + messagePing > 250) {
color = client.afk
} else {
color = ':green_circle:'
color = client.online
}
// let embed = new Discord.MessageEmbed().setAuthor(message.author.tag, message.author.avatarURL(), `https://github.com/Ezzud/tadaa`).setColor('17F0C9').addField(`\u200B`, lang.pingStart).setFooter(lang.footer.split("%version%").join(json.version))
message.channel.send(lang.pingEnd.split("%messagePing%").join(messagePing).split("%apiPing%").join(apiPing).split("%color%").join(color))
/* message.channel.send(lang.pingStart).then(msg => {
let embed = new Discord.MessageEmbed().setAuthor(message.author.tag, message.author.avatarURL(), `https://github.com/Ezzud/tadaa`).setColor(color).addField(`\u200B`, lang.pingEnd.split("%messagePing%").join(messagePing).split("%apiPing%").join(apiPing)).setFooter(lang.footer.split("%version%").join(json.version))
msg.edit(lang.pingEnd.split("%messagePing%").join(messagePing).split("%apiPing%").join(apiPing).split("%color%").join(color))
})*/
}
module.exports.help = {
name: "ping"
Expand Down
44 changes: 32 additions & 12 deletions commands/reload.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,40 @@ const loadings = `<a:erjbgtuezrftetgfret:688433071573565440>`
function getEmoji(name) {
return `<:${name}:${emojiMap[name]}>`;
}
module.exports.run = async (client, pf, message, args, manager,json,lang) => {
console.log = function(d) {
let date = new Date();
date.setHours(date.getHours() + 2); //
fs.appendFileSync(`${client.logs_path}`, `\n(${commandname}) ${moment(date).format('MM-D-YYYY hh:mm')} | ${d}`, "UTF-8",{'flags': 'a+'});
log_stdout.write(`SHARD #${client.shard.ids[0]} ` + util.format(d) + '\n');
};
module.exports.run = async (client, pf, message, args, manager, json, lang) => {
console.log = function(d) {
let date = new Date();
date.setHours(date.getHours() + 2); //
fs.appendFileSync(`${client.logs_path}`, `\n(${commandname}) ${moment(date).format('MM-D-YYYY hh:mm')} | ${d}`, "UTF-8", {
'flags': 'a+'
});
log_stdout.write(`SHARD #${client.shard.ids[0]} ` + util.format(d) + '\n');
};
if (message.author.id === settings.ownerID) {
let emoji = loadings;
let reloadEmbed = new Discord.MessageEmbed().setColor('D7E921').setDescription(`\u200B`).setAuthor(message.author.tag, message.author.avatarURL(), `https://github.com/Ezzud/tadaa`).addField(`\nEtat`, `${emoji} Redémarrage du shard \` ${client.shard.ids[0]} \` en cours\n\u200B`).setFooter(`TADAA | v${json.version}`)
await message.channel.send(reloadEmbed);
let sendedMessage = await message.channel.send(reloadEmbed);
let dater = new Date().getTime();
await client.destroy()
await client.login(settings.token)
async function addCommands() {
await fs.readdir("./commands/", async (err, files) => {
if (err) console.log(err);
var jsfile = files.filter(f => f.split(".").pop() === "js");
if (jsfile.length <= 0) {
console.log("../commands/ is empty!");
return;
}
var f;
for (f in jsfile) {
const commandName = jsfile[f].split(".")[0];
delete require.cache[require.resolve(`./${commandName}.js`)];
await client.commands.delete(commandName);
const props = require(`../commands/${commandName}.js`);
await client.commands.set(commandName, props);
}
console.log(`\x1b[32m` + ` \x1b[32mSuccesfully reloaded \x1b[33m${client.commands.size} \x1b[32mcommands` + `\x1b[0m`);
});
}
await addCommands()
let datef = new Date().getTime();
let time = datef - dater;
time = time / 1000
Expand All @@ -52,8 +72,8 @@ console.log = function(d) {
values.forEach((value) => {
count = count + 1
});
let reloadedEmbed = new Discord.MessageEmbed().setColor('5BCA2F').setDescription(`\u200B`).setAuthor(message.author.tag, message.author.avatarURL(), `https://github.com/Ezzud/tadaa`).addField(`\nEtat`, `${client.okay} Redémarrage du shard \` ${client.shard.ids[0]} \` effectué (*${time}s*)`).addField(`Shards`, `\`${count}\`/\`${client.shard.count}\`\n\u200B`).setFooter(`TADAA | v${json.version}`)
await message.channel.send(reloadedEmbed)
let reloadedEmbed = new Discord.MessageEmbed().setColor('5BCA2F').setDescription(`\u200B`).setAuthor(message.author.tag, message.author.avatarURL(), `https://github.com/Ezzud/tadaa`).addField(`\nEtat`, `${client.okay} Redémarrage du shard \` ${client.shard.ids[0]} \` effectué (*${time}s*)\nCommandes rechargées: **${client.commands.size}**`).addField(`Shards`, `\`${count}\`/\`${client.shard.count}\`\n\u200B`).setFooter(lang.footer.split("%version%").join(json.version))
await sendedMessage.edit(reloadedEmbed)
}
}
module.exports.help = {
Expand Down
Loading

0 comments on commit be539c0

Please sign in to comment.