Kod Discord.JS v13 "Context" Kullanıcı Bilgi Komutu

kedy

.gg/amongusturkiye
Yönetici
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.

apps.png
apps2.png

./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
 
°Syniox™#0666
Katılım
10 Şub 2022
Mesajlar
2
Tepkime puanı
0
hiç bişi anlamadım keşe açıklasan
 
selim#1337
Katılım
29 Tem 2022
Mesajlar
75
Tepkime puanı
22
Şehir
İstanbul
Selamlar iyi günler sslere göre bakılınca mükemmel bir komut yazmışsınız fakat ben böyle bir hata alıyorum nedeni nedir acaba yardımcı olma şansınız var mı
//Command Handler Bu kısımda hep hata veriyor nedeni ne olabilir hocam discord dan da ulaşabilirsiniz
const commands = [];
const commandFiles = readdirSync('./src/komutlar').filter(file => file.endsWith('.js'));
for (const file of commandFiles) { const command = require(`./src/komutlar/${file}`); commands.push(command.data.toJSON());
client.commands.set(command.data.name, command);
}

Ekli dosyayı görüntüle 5073
 
selim#1337
Katılım
29 Tem 2022
Mesajlar
75
Tepkime puanı
22
Şehir
İstanbul
Hata ssi bu
 

Ekli dosyalar

  • Ekran Alıntısı.PNG
    Ekran Alıntısı.PNG
    44.1 KB · Görüntüleme: 141

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

  • Bilgi