Yardım .verilerim komutunda bulunan istatistikleri .puan komutuna uygun olarak ekleyen ek bir komut istiyorum

bizeheryerhacapit
Katılım
18 Haz 2022
Mesajlar
5
Tepkime puanı
8
Şehir
Rize
discord.js v14 altyapısında bulunan .verilerim komutunun kodu ```const { PermissionFlagsBits, ButtonStyle, ButtonBuilder, ActionRowBuilder, Events, EmbedBuilder, StringSelectMenuBuilder, ComponentType, codeBlock } = require("discord.js");
const beş_config = require("../../../beş_config")
const client = global.client;
const db = client.db;
const moment = require("moment");
require("moment-duration-format")
moment.locale("tr");
const messageUserChannel = require("../../beş_schemas/messageChannelsSchema");
const voiceUserChannel = require("../../beş_schemas/voiceChannelsSchema");
const messageUser = require("../../beş_schemas/messagesSchema");
const voiceUser = require("../../beş_schemas/voicesSchema");
const voiceUserParent = require("../../beş_schemas/voiceParentsSchema");
const invite = require("../../beş_schemas/invitesSchema");
module.exports = {
name: "stat",
usage: "stat [@Beş / ID]",
category: "stat",
aliases: ["stats", "me", "istatistik", "verilerim"],
execute: async (client, message, args, beş_embed) => {

const member = message.mentions.members.first() || message.guild.members.cache.get(args[0]) || message.member;

let erkek = await db.get(`erkek-${member.id}`) || 0;
let kadın = await db.get(`kadın-${member.id}`) || 0;

const category = async (parentsArray) => {
const data = await voiceUserParent.find({ guildId: message.guild.id, userId: member.user.id });
const voiceUserParentData = data.filter((x) => parentsArray.includes(x.parentId));
let voiceStat = 0;
for (var i = 0; i <= voiceUserParentData.length; i++) { voiceStat += voiceUserParentData ? voiceUserParentData.parentData : 0; }
return moment.duration(voiceStat).format("H [Saat], m [Dakika], s [Saniye]");
};

const Active1 = await messageUserChannel.find({ guildId: message.guild.id, userId: member.user.id }).sort({ channelData: -1 });
const Active2 = await voiceUserChannel.find({ guildId: message.guild.id, userId: member.user.id }).sort({ channelData: -1 });
const voiceLength = Active2 ? Active2.length : 0;
const chatLength = Active1 ? Active1.length : 0;
let voiceTop;
let messageTop;
Active1.length > 0 ? (messageTop = Active1.splice(0, 5).map((x) => `<#${x.channelId}>: \`${Number(x.channelData).toLocaleString()} Mesaj\``).join("\n")) : (messageTop = "*Veri Bulunmamakta*");
Active2.length > 0 ? (voiceTop = Active2.splice(0, 5).map((x) => `<#${x.channelId}>: \`${moment.duration(x.channelData).format("H [Saat], m [Dakika], s [Saniye]")}\``).join("\n")) : (voiceTop = "*Veri Bulunmamakta*");
const messageData = await messageUser.findOne({ guildId: message.guild.id, userId: member.user.id });
const voiceData = await voiceUser.findOne({ guildId: message.guild.id, userId: member.user.id });
const messageDaily = messageData ? messageData.dailyStat : 0;
const messageWeekly = messageData ? messageData.weeklyStat : 0;
const voiceDaily = moment.duration(voiceData ? voiceData.dailyStat : 0).format("H [Saat], m [Dakika], s [Saniye]");
const voiceWeekly = moment.duration(voiceData ? voiceData.weeklyStat : 0).format("H [Saat], m [Dakika], s [Saniye]");
const cameraData = moment.duration(voiceData ? voiceData.cameraStat : 0).format("H [Saat], m [Dakika], s [Saniye]");
const streamData = moment.duration(voiceData ? voiceData.streamStat : 0).format("H [Saat], m [Dakika], s [Saniye]");
const invites = await invite.findOne({ guildId: message.guild.id, userId: member.user.id });

const beş_dropdown = new ActionRowBuilder()
.addComponents(
new StringSelectMenuBuilder()
.setCustomId(`me`)
.setPlaceholder("Filtrelenmiş Veriler İçin Tıkla!")
.addOptions([
{ label: `Anasayfa`, description: `Anasayfaya Dönmek İçin Tıkla!`, value: `anasayfa5`, emoji: `${client.emoji("emote_web") !== null ? client.emoji("emote_web"):"1105493458933792819"}` },
{ label: `Günlük Veriler`, description: `Günlük Verileri Görmek İçin Tıkla!`, value: `gun`, emoji: `${client.emoji("emote_time") !== null ? client.emoji("emote_time"):"1105494402136285376"}` },
{ label: `Haftalık Veriler`, description: `Haftalık Verileri Görmek İçin Tıkla!`, value: `hafta`, emoji: `${client.emoji("emote_time") !== null ? client.emoji("emote_time"):"1105494402136285376"}` },
{ label: `Toplam Veriler`, description: `Toplam Verileri Görmek İçin Tıkla!`, value: `toplam`, emoji: `${client.emoji("emote_time") !== null ? client.emoji("emote_time"):"1105494402136285376"}` },
{ label: `Kategori Verileri`, description: `Kategori Verilerini Görmek İçin Tıkla!`, value: `kategori`, emoji: `${client.emoji("emote_others") !== null ? client.emoji("emote_others"):"1102624779950895134"}` },
{ label: `Kamera Verileri`, description: `Kamera Verilerini Görmek İçin Tıkla!`, value: `kamera`, emoji: `${client.emoji("emote_camera") !== null ? client.emoji("emote_camera"):"1105493457453187162"}` },
{ label: `Yayın Verileri`, description: `Yayın Verilerini Görmek İçin Tıkla!`, value: `yayın`, emoji: `${client.emoji("emote_computer") !== null ? client.emoji("emote_computer"):"1102621545022627850"}` },
{ label: `Kayıt Verileri`, description: `Kayıt Verilerini Görmek İçin Tıkla!`, value: `kayıt`, emoji: `${client.emoji("emote_others") !== null ? client.emoji("emote_others"):"1102624779950895134"}` }]))

beş_embed.setThumbnail(member.user.displayAvatarURL({ dynamic: true, size: 2048 }))
beş_embed.setDescription(`> **${member.user.toString()} Kullanıcısının <t:${Math.floor(Date.now()/1000)}:R>ki Verileri;**\n⠀\n`)
beş_embed.addFields([{name: `${client.emoji("emote_chat") !== null ? client.emoji("emote_chat"):"💭"} • **Toplam Mesaj**`, value: codeBlock("fix",`${messageData ? messageData.topStat : 0} Mesaj`)},
{name: `${client.emoji("emote_voice") !== null ? client.emoji("emote_voice"):"🔉"} • **Toplam Ses**`, value: codeBlock("fix",`${moment.duration(voiceData ? voiceData.topStat : 0).format("H [Saat], m [Dakika], s [Saniye]")}`)},
{name: `${client.emoji("emote_invite") !== null ? client.emoji("emote_invite"):"📩"} • **Toplam Davet**`, value: codeBlock("js",`Gerçek: ${invites ? invites.Regular : 0}, Sahte: ${invites ? invites.Fake : 0}, Ayrılan: ${invites ? invites.Left : 0}, Bonus: ${invites ? invites.Bonus : 0}`)}])
beş_embed.addFields([{name:"⠀", value:`⠀`}]);
beş_embed.addFields([{name:`${client.emoji("emote_value") !== null ? client.emoji("emote_value"):"🔹"} • **Sohbet Ettiğin Chat Kanalları:**\n> **(\`Toplam ${chatLength} Kanal\`)**`,value: `${messageTop}`}]);
beş_embed.addFields([{name:`${client.emoji("emote_value") !== null ? client.emoji("emote_value"):"🔹"} • **Vakit Geçirdiğin Voice Kanalları:**\n> **(\`Toplam ${voiceLength} Kanal\`)**`,value:`${voiceTop}`}]);
beş_embed.setFooter({text:`Menü Üzerinden Verilerinize Filtre Uygulayabilirsiniz`,iconURL:member.user.avatarURL({ dynamic: true, size: 2048 })})

message.reply({ embeds: [beş_embed], components: [beş_dropdown] }).then(b2 => {

const filter = i => i.user.id === message.member.id;
const collector = b2.createMessageComponentCollector({componentType:ComponentType.StringSelect, filter: filter, time: 60000 });

collector.on('end', async b => {
beş_dropdown.components[0].setDisabled(true);
b2.edit({ content: `> **Menü Zaman Aşımına Uğradı..**`, components: [beş_dropdown] })
})
collector.on('collect', async b => {
if (!b.isStringSelectMenu()) return;
const value = b.values[0]
const daily_bes = new EmbedBuilder()
.setDescription(`> **${member.user.toString()} Kullanıcısının Günlük Ses Ve Mesaj Verileri;**`)
.addFields([{name:`${client.emoji("emote_chat") !== null ? client.emoji("emote_chat"):"💭"} • **Günlük Mesaj**`,value:codeBlock("fix",`${Number(messageDaily).toLocaleString()} Mesaj`)}])
.addFields([{name:`${client.emoji("emote_voice") !== null ? client.emoji("emote_voice"):"🔉"} • **Günlük Ses**`,value:codeBlock("fix",`${voiceDaily}`)}]).setColor(`#2f3136`).setTitle(`Günlük Veriler`).setURL(` `).setThumbnail(member.user.displayAvatarURL({ dynamic: true, size: 2048 }))


const weekly_bes = new EmbedBuilder()
.setDescription(`> **${member.user.toString()} Kullanıcısının Haftalık Ses Ve Mesaj Verileri;**`)
.addFields([{name:`${client.emoji("emote_chat") !== null ? client.emoji("emote_chat"):"💭"} • **Haftalık Mesaj**`,value:codeBlock("fix",`${Number(messageWeekly).toLocaleString()} Mesaj`)}])
.addFields([{name:`${client.emoji("emote_voice") !== null ? client.emoji("emote_voice"):"🔉"} • **Haftalık Ses**`,value:codeBlock("fix",`${voiceWeekly}`)}]).setColor(`#2f3136`).setTitle(`Haftalık Veriler`).setURL(` `).setThumbnail(member.user.displayAvatarURL({ dynamic: true, size: 2048 }))

const total_bes = new EmbedBuilder()
.setDescription(`> **${member.user.toString()} Kullanıcısının Haftalık Ses Ve Mesaj Verileri;**`)
.addFields([{name:`${client.emoji("emote_chat") !== null ? client.emoji("emote_chat"):"💭"} • **Toplam Mesaj**`,value:codeBlock("fix",`${messageData ? messageData.topStat : 0} Mesaj`)}])
.addFields([{name:`${client.emoji("emote_voice") !== null ? client.emoji("emote_voice"):"🔉"} • **Toplam Ses**`,value:codeBlock("fix",`${moment.duration(voiceData ? voiceData.topStat : 0).format("H [Saat], m [Dakika], s [Saniye]")}`)}]).setColor(`#2f3136`).setTitle(`Toplam Veriler`).setURL(` `).setThumbnail(member.user.displayAvatarURL({ dynamic: true, size: 2048 }))


const cat_bes = new EmbedBuilder()
.setDescription(`> **${member.user.toString()} Kullanıcısının Kategori Verileri;**`)
.addFields([{name:`**${client.emoji("emote_others") !== null ? client.emoji("emote_others"):"❓"} • Kategori Bilgileri:**`,value:`
**${client.emoji("emote_value") !== null ? client.emoji("emote_value"):"🔹"} • Toplam: \`${moment.duration(voiceData ? voiceData.topStat : 0).format("H [Saat], m [Dakika], s [Saniye]")}\`**
**${client.emoji("emote_value") !== null ? client.emoji("emote_value"):"🔹"} • Public & Sohbet: \`${await category(beş_config.parents.publicParents)}\`**
**${client.emoji("emote_value") !== null ? client.emoji("emote_value"):"🔹"} • Kayıt & Welcome: \`${await category(beş_config.parents.registerParents)}\`**
**${client.emoji("emote_value") !== null ? client.emoji("emote_value"):"🔹"} • Sorun Çözme & Terapi: \`${await category(beş_config.parents.solvingParents)}\`**
**${client.emoji("emote_value") !== null ? client.emoji("emote_value"):"🔹"} • Private & Alone: \`${await category(beş_config.parents.privateParents)}\`**
**${client.emoji("emote_value") !== null ? client.emoji("emote_value"):"🔹"} • Oyun & Stream: \`${await category(beş_config.parents.aloneParents)}\`**
**${client.emoji("emote_value") !== null ? client.emoji("emote_value"):"🔹"} • Konser & Eğlence: \`${await category(beş_config.parents.funParents)}\`**`}]
).setColor(`#2f3136`).setTitle(`Kategori Verileri`).setURL(` `).setThumbnail(member.user.displayAvatarURL({ dynamic: true, size: 2048 }))

const camera_bes = new EmbedBuilder()
.setDescription(`> **${member.user.toString()} Kullanıcısının Kamera Verileri;**`)
.addFields([{name:`${client.emoji("emote_camera") !== null ? client.emoji("emote_camera"):"📸"} • **Kamera Verisi**`,value:codeBlock("fix",`${cameraData}`)}]).setColor(`#2f3136`).setTitle(`Kamera Verileri`).setURL(` `).setThumbnail(member.user.displayAvatarURL({ dynamic: true, size: 2048 }))

const stream_bes = new EmbedBuilder()
.setDescription(`> **${member.user.toString()} Kullanıcısının Yayın Verileri;**`)
.addFields([{name:`${client.emoji("emote_computer") !== null ? client.emoji("emote_computer"):"🖥️"} • **Yayın Verisi**`,value:codeBlock("fix",`${streamData}`)}]).setColor(`#2f3136`).setTitle(`Yayın Verileri`).setURL(` `).setThumbnail(member.user.displayAvatarURL({ dynamic: true, size: 2048 }))

const kayıt_bes = new EmbedBuilder()
.setDescription(`> **${member.user.toString()} Kullanıcısının Kayıt Verileri;**`)
.addFields([{name:`${client.emoji("emote_others") !== null ? client.emoji("emote_others"):"🖋️"} • **Kayıt Verisi**`,value:codeBlock("fix",`Erkek; ${erkek}, Kız; ${kadın}, Toplam; ${(erkek+kadın)}`)}]).setColor(`#2f3136`).setTitle(`Kayıt Verileri`).setURL(` `).setThumbnail(member.user.displayAvatarURL({ dynamic: true, size: 2048 }))

if (value === `anasayfa5`) {
await b.update({ embeds: [beş_embed] })
}

if (value === `gun`) {
await b.update({ embeds: [daily_bes] })
}

if (value === `hafta`) {
await b.update({ embeds: [weekly_bes] })
}

if (value === `toplam`) {
await b.update({ embeds: [total_bes] })
}

if (value === `kategori`) {
await b.update({ embeds: [cat_bes] })
}

if (value === `kamera`) {
await b.update({ embeds: [camera_bes] })
}

if (value === `yayın`) {
await b.update({ embeds: [stream_bes] })
}

if (value === `kayıt`) {
await b.update({ embeds: [kayıt_bes] })
}

})
})

}
}```, .puan konutunun kodu ise ```const { PermissionFlagsBits, ButtonStyle, ButtonBuilder, ActionRowBuilder, Events, beş_embedBuilder, StringSelectMenuBuilder, ComponentType, codeBlock, beş_embed } = require("discord.js");
const beş_config = require("../../../beş_config")
const client = global.client;
const db = client.db;
const ms = require("ms")
const moment = require("moment");
require("moment-duration-format")
moment.locale("tr");
const canvafy = require("canvafy");
const messageGuild = require("../../beş_schemas/messageGuildSchema");
const messageGuildChannel = require("../../beş_schemas/messageGuildChannelsSchema");
const voiceGuild = require("../../beş_schemas/voiceGuildSchema");
const voiceGuildChannel = require("../../beş_schemas/voiceGuildChannelsSchema");
const messageUser = require("../../beş_schemas/messagesSchema");
const voiceUser = require("../../beş_schemas/voicesSchema");
const point = require("../../beş_schemas/staffsSchema");
const invite = require("../../beş_schemas/invitesSchema");
const task = require("../../beş_schemas/tasksSchema");
module.exports = {
name: "puan",
usage: "puan [+/-] [@Beş / ID] <Adet>",
category: "stat",
aliases: ["puans", "bonuspuan", "puanekle","puan-ekle"],
execute: async (client, message, args, beş_embed) => {
if(!message.member.permissions.has(PermissionFlagsBits.Administrator))return message.reply({embeds:[beş_embed.setDescription(`> **Yeterli Yetki Bulunmamakta!**`)]}).sil(5);

const msgMember = message.member;

if(!args[0])return message.reply({ embeds: [beş_embed.setDescription("> **Eksik Argüman Belirtmelisin!**\n> *ekle / sil / gönder*")] });
const member = message.mentions.members.first() || message.guild.members.cache.get(args[1]);
if (!member) return message.reply({ embeds: [beş_embed.setDescription("> **Bir Kullanıcı Belirtmelisin!**")] });
if (args[0] === "ekle") {
if (!message.member.permissions.has(PermissionFlagsBits.Administrator)) return message.reply({ embeds: [beş_embed.setDescription(`> ** Komutu Kullanmak İçin Yetkin Bulunmamakta!**`)] }).sil(5);
const count = parseInt(args[2]);
if (!count) return message.reply({ embeds: [beş_embed.setDescription("> **Eklemek İçin Bir Sayı Belirtmelisin!**")] });
if (!count < 0) return message.reply({ embeds: [beş_embed.setDescription("> **Eklenecek Sayı 0'dan Küçük Olamaz!**")] });

await point.updateOne({ guildId: member.guild.id, userId: member.user.id }, { $inc: { point: count } }, { upsert: true });
const pointData = await point.findOne({ guildId: member.guild.id, userId: member.user.id });
let addedRoles = "";
if (pointData && client.ranks.some((x) => pointData.point >= x.point && !member.hasRole(x.role))) {
const roles = client.ranks.filter((x) => pointData.point >= x.point && !member.hasRole(x.role));
addedRoles = roles;
member.roles.add(roles[roles.length - 1].role);
beş_embed.setColor("#00ff00");
client.kanalbul("rank-log").send({
embeds: [
beş_embed.setDescription(
`> **${member.toString()} Üyesine ${msgMember.toString()} Tarafından ${count} Adet Puan Eklendi Ve Kişiye** ${roles
.filter((x) => roles.indexOf(x) === roles.length - 1)
.map((x) => (Array.isArray(x.role) ? x.role.listRoles() : `<@&${x.role}>`))
.join("\n")} **Rolleri Verildi!**`
)
]
});
}
message.reply({
embeds: [
beş_embed.setDescription(
`> **Başarıyla ${member.toString()} Kullanıcısına ${count} Adet Puan Eklendi! **\n\n${
addedRoles.length > 0
? `**Verilen Roller: **\n${addedRoles
.filter((x) => addedRoles.indexOf(x) === addedRoles.length - 1)
.map((x) => (Array.isArray(x.role) ? x.role.listRoles() : `<@&${x.role}>`))
.join("\n")}`
: ""
}`
)
]
});
} else if (args[0] === "sil") {
if (!message.member.permissions.has("ADMINISTRATOR")) return message.reply({ embeds: [beş_embed.setDescription(`> **${config.emojis.no} Komutu Kullanmak İçin Yetkin Bulunmamakta!**`)] }).catch((err) => console.log(err), client.tick(message)).then((e) => setTimeout(() => { e.delete(); }, 10000));
const count = parseInt(args[2]);
if (!count) return message.reply({ embeds: [beş_embed.setDescription("> **Çıkarılacak Bir Sayı Belirtmelisin!**")] });
if (!count < 0) return message.reply({ embeds: [beş_embed.setDescription("> **Çıkarılacak Sayı 0'dan Küçük Olamaz!**")] });
let pointData = await point.findOne({ guildId: member.guild.id, userId: member.user.id });
if (!pointData || (pointData && count > pointData.point)) return message.reply({ embeds: [beş_embed.setDescription("> **Çıkarmak İstediğiniz Sayı Kişinin Mevcut Puanından Büyük Olamaz!**")] });

await point.updateOne({ guildId: member.guild.id, userId: member.user.id }, { $inc: { point: -count } }, { upsert: true });
pointData = await point.findOne({ guildId: member.guild.id, userId: member.user.id });
let removedRoles = "";
if (pointData && client.ranks.some((x) => pointData.point < x.point && member.hasRole(x.role))) {
const roles = client.ranks.filter((x) => pointData.point < x.point && member.hasRole(x.role));
removedRoles = roles;
roles.forEach((x) => {
member.roles.remove(x.role);
});
beş_embed.setColor("#ff0000");
client.kanalbul("rank-log").send({
embeds: [
beş_embed.setDescription(
`> **${member.toString()} Üyesinden ${msgMember.toString()} Tarafından ${count} Adet Puan Çıkarıldı Ve Kişiden** ${
Array.isArray(roles) ? roles.listRoles() : `<@&${roles}}>`
} **Rolleri Alındı!**`
)
]
});
}
message.reply({
embeds: [
beş_embed.setDescription(
`> **Başarıyla ${member.toString()} Kullanıcısından ${count} Adet Puan Çıkarıldı!**\n\n${
removedRoles.length > 0 ? `**Alınan Roller:** \n${removedRoles.listRoles()}` : ""
}`
)
]
});
} else if (args[0] === "gönder") {
const count = parseInt(args[2]);
if (!count) return message.reply({ embeds: [beş_embed.setDescription("> **Puan Vermek İçin Bir Sayı Belirtmelisin!**")] });
if (!count < 0) return message.reply({ embeds: [beş_embed.setDescription("> **Verilecek Sayı 0'dan Küçük Olamaz!**")] });
let pointData = await point.findOne({ guildId: member.guild.id, userId: msgMember.user.id });
if (!pointData || (pointData && count > pointData.point)) return message.reply({ embeds: [beş_embed.setDescription("> **Göndereceğin Puan Kendi Puanından Yüksek Olamaz!**")] });

await point.updateOne({ guildId: member.guild.id, userId: member.user.id }, { $inc: { point: count } }, { upsert: true });
await point.updateOne({ guildId: member.guild.id, userId: msgMember.user.id }, { $inc: { point: -count } }, { upsert: true });
pointData = await point.findOne({ guildId: member.guild.id, userId: msgMember.user.id });
if (pointData && client.ranks.some((x) => pointData.point < x.point && msgMember.hasRole(x.role))) {
const roles = client.ranks.filter((x) => pointData.point < x.point && msgMember.hasRole(x.role));
roles.forEach((x) => msgMember.roles.remove(x.role));
}
const pointData2 = await point.findOne({ guildId: member.guild.id, userId: member.user.id });
if (pointData2 && client.ranks.some((x) => pointData2.point >= x.point && !member.hasRole(x.role))) {
const roles = client.ranks.filter((x) => pointData2.point >= x.point && !member.hasRole(x.role));
member.roles.add(roles[roles.length - 1].role);
}

message.reply({ embeds: [beş_embed.setDescription(`> **${member.toString()} Kişisine ${count} Puan Gönderildi!**`)] });
}else{
return message.reply({ embeds: [beş_embed.setDescription("> **Eksik Argüman Belirtmelisin!**\n> *ekle / sil / gönder*")] });

}


}
}```. '.verilerim' komutundaki verileri '.puan' komutundaki özelliğe göre ayarlayan ve '.puan' komutu girildiğinde '.verilerim' verilerinin '.puan' komutuna özel ayarlayan ek bir komut için kod istiyorum
 
Konu Sahibi
Wasteros
bizeheryerhacapit
Katılım
18 Haz 2022
Mesajlar
5
Tepkime puanı
8
Şehir
Rize
bu arada kodu örnek olarak yazdım bana ait değil kendi kodumu örnekte veremem
 

Konuyu 1 kişi okuyor. (0 kayıtlı üye ve 1 ziyaretçi)

Benzer konular

  • Bilgi