Skip to content

Commit

Permalink
Update 5.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Adivise authored Sep 29, 2022
1 parent 6eaf330 commit b05341e
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 1 deletion.
50 changes: 50 additions & 0 deletions commands/Utilities/TopChart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const { EmbedBuilder } = require("discord.js");
const { Database } = require("st.db");
const ytsr = require("@distube/ytsr");

const SStats = new Database("./settings/models/chart.json", { databaseInObject: true });

module.exports = {
name: ["topchart"],
description: "Display top song most recent playable.",
category: "Utilities",
run: async (client, interaction) => {
await interaction.deferReply({ ephemeral: false });

const all = SStats.all().slice(0, 10);

all.sort((a, b) => {
return b.data - a.data;
});

var index = 0;

for (let i = 0; i < all.length; i++) {
const total = all[i].data;
index = (index + total)
}

const TopChart = [];
for (let i = 0; i < all.length; i++) {
const format = `https://youtu.be/${all[i].ID}`;
const search = await ytsr(format);
const track = search.items[0];

TopChart.push(
`**${i + 1}.** [${track.name}](${track.url}) | **Playable:** \`${all[i].data}\`
`)
}

const str = TopChart.join('');

const embed = new EmbedBuilder()
.setColor(client.color)
.setAuthor({ name: `Top Charts`, iconURL: interaction.guild.iconURL({ dynamic: true })})
.setThumbnail(client.user.displayAvatarURL({ dynamic: true, size: 2048 }))
.setDescription(`${str == '' ? ' No Playable' : '\n' + str}`)
.setFooter({ text: `Total Song • ${SStats.all().length} | Total Playable • ${index}` })


return interaction.editReply({ embeds: [embed] })
}
}
48 changes: 48 additions & 0 deletions commands/Utilities/UsableStats.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const { EmbedBuilder } = require("discord.js");
const { Database } = require("st.db");

const BStats = new Database("./settings/models/stats.json", { databaseInObject: true });

module.exports = {
name: ["usablestats"],
description: "Display all commands stats usable.",
category: "Utilities",
run: async (client, interaction) => {
await interaction.deferReply({ ephemeral: false });

const all = BStats.all().slice(0, 10);

all.sort((a, b) => {
return b.data - a.data;
});

var index = 0;

for (let i = 0; i < all.length; i++) {
const total = all[i].data;
index = (index + total)
}

const TopUsable = [];
for (let i = 0; i < all.length; i++) {
const name = all[i].ID.UppertoLowerCase();
const usable = all[i].data;

TopUsable.push(
`**${i + 1}.** ${name} | **Usable:** \`${usable}\`
`)
}

const str = TopUsable.join('');

const embed = new EmbedBuilder()
.setColor(client.color)
.setAuthor({ name: `Usable Commands!`, iconURL: interaction.guild.iconURL({ dynamic: true })})
.setThumbnail(client.user.displayAvatarURL({ dynamic: true, size: 2048 }))
.setDescription(`${str == '' ? ' No Usable' : '\n' + str}`)
.setFooter({ text: `Total Command • ${BStats.all().length} | Total Usable • ${index}` })


return interaction.editReply({ embeds: [embed] })
}
}
1 change: 1 addition & 0 deletions events/distube/playSong.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const GSetup = new Database("./settings/models/setup.json", { databaseInObject:
module.exports = async (client, queue, track) => {

await client.UpdateQueueMsg(queue);
await client.addChart(track.id);

const db = await GSetup.get(queue.textChannel.guild.id);
if (db.setup_enable === true) return;
Expand Down
1 change: 1 addition & 0 deletions events/guild/interactionCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ module.exports = async(client, interaction) => {
if (!command) return;
if (command) {
try {
client.addCount(command.name.at(-1));
command.run(client, interaction);
} catch (error) {
console.log(error);
Expand Down
12 changes: 11 additions & 1 deletion handlers/loadDatabase.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,23 @@ module.exports = async (client) => {

client.createPlay = async function (interaction, message) {
const db = new Database("./settings/models/message.json", { databaseInObject: true });

await db.set(interaction.guild.id, {
channel_id: interaction.channel.id,
message_id: message
});
};

client.addCount = async function (cmdname) {
const db = new Database("./settings/models/stats.json", { databaseInObject: true });
await db.add({ key: cmdname, value: 1 });
}

client.addChart = async function (id) {
const db = new Database("./settings/models/chart.json", { databaseInObject: true });
await db.add({ key: id, value: 1 });
}


client.interval = null;

client.clearInterval = async function (interval) {
Expand Down
1 change: 1 addition & 0 deletions settings/models/chart.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions settings/models/stats.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}

0 comments on commit b05341e

Please sign in to comment.