- kedy0
- Katılım
- 14 Eyl 2021
- Mesajlar
- 379
- Tepkime puanı
- 322
- Şehir
- İstanbul
Selam dostlar! Bugün sizlere çoğu yerde aranan "context menu" kodlarından birini vereceğim. Komutun amacı kişiye sağ tıklayarak sunucu içerisindeki bilgilerini görüntülemek.
Context Menu : Sağ tıklayarak açılan ve üzerinde olunan öğeye göre değişen menü türü. v13 güncellemesi ile birlikte eklenmiştir.
./komutlar/context/profil.js
Context Menu : Sağ tıklayarak açılan ve üzerinde olunan öğeye göre değişen menü türü. v13 güncellemesi ile birlikte eklenmiştir.
./komutlar/context/profil.js
JavaScript:
const Command = require("../../structures/CommandClass");
const { MessageEmbed } = require("discord.js");
const { stripIndents } = require("common-tags");
module.exports = class UserInfo extends Command {
constructor(client) {
super(client, {
name: "Kullanıcı Bilgisi",
type: "USER",
defaultPermission: true,
contextDescription: "Kullanıcı bilgisi.",
category: "Context",
cooldown: 5,
enabled: true,
staffOnly: false,
permissions: ["Use Application Commands", "Send Messages", "Embed Links"]
});
}
async run(client, interaction) {
const member = interaction.guild.members.cache.get(interaction.targetId);
const embed = new MessageEmbed()
.setTitle(`**${member.user.username}#${member.user.discriminator}**`)
.setColor(client.config.embedColor)
.setThumbnail(member.user.displayAvatarURL({ dynamic: true, size: 2048 }))
.addFields(
{
name: "👤 Kullanıcı Bilgisi",
value: stripIndents`
**ID:** ${member.user.id}
**Oluşturma Tarihi:** <t:${Math.floor(member.user.createdTimestamp / 1000)}:d>
`,
inline: true
},
{
name: "📋 Kullanıcı'nın Diğer Bilgileri",
value: stripIndents`
**Sunucuya Giriş tarihi:** <t:${Math.floor(member.joinedTimestamp / 1000)}:R>
**Kullanının ismi:** ${member.nickname || `Varsayılan`}
**Rolü:** ${member.roles.hoist ? member.roles.hoist.name : "Bulunmuyor."}
`,
inline: true
},
{
name: 👁🗨 Kullanıcı'nın Rolleri[${member.roles.cache.size - 1}]`,
value: member.roles.cache.size ? member.roles.cache.map(roles => `**${roles}**`).slice(0, -1).join(" ") : "None", // Supēsu#0001
inline: false
}
);
interaction.reply({ embeds: [embed] });
}
};
const Command = require("../../structures/CommandClass");
JavaScript:
module.exports = class Command {
constructor(client, meta = {}) {
this.client = client;
this.name = meta.name;
this.type = meta.type;
this.description = meta.description || null;
this.options = meta.options || [];
this.defaultPermission = meta.defaultPermission;
this.contextDescription = meta.contextDescription;
this.usage = meta.usage || this.name;
this.category = meta.category || "Info";
this.permissions = meta.permissions || ["Use Application Commands", "Send Messages", "Embed Links"];
}
async run(message, run) {
throw new Error(`The Slash Command "${this.name}" does not provide a run method.`);
}
};
Komutu kendinize göre şekillendirebilirsiniz, Like butonuna basmayı unutmazsanız sevinirim <3