Discord botunuza ekleyebileceğiniz komutları görmek için tıklayın.
Discord js kullanılarak yazılmış bir rol geri alma, üyeden rol kaldırma komutu. Böylece rolleri yönet yetkisine sahip olan tüm yetkililer kullanıcıların rollerini geri alabilecek.
Kurulum için aşağıdaki adımları izleyin;
- Bu kod projenizdeki komutlar ya da commands adındaki klasöre atılmalıdır. Eğer eklemeyi bilmiyorsanız buraya tıklayın.
- Komut içerisindeki gerekli yerleri kendinize göre düzenleyebilirsiniz.
- Gerekli modüller; Discord.js
Discord.js v12 için;
// Komutlar klasörüne atılmalıdır.
// Bu komut Staup tarafından hazırlanmıştır.
const { Message } = require("discord.js");
exports.run = (client, message, args) => {
if (!message.member.hasPermission("MANAGE_ROLES")) {
return message.reply("Bu komutu kullanma izniniz yok.");
}
const member = message.mentions.members.first();
if (!member) {
return message.reply("Lütfen bir üye etiketleyin.");
}
if (args.length < 2) {
return message.reply("Alınacak rolleri belirtmelisiniz.");
}
const rolesToGrant = message.mentions.roles;
rolesToGrant.forEach((role) => {
if (!member.roles.cache.has(role.id)) {
member.roles
.remove(role)
.then(() => {
message.channel.send(
`Başarıyla ${role.name} rolünü ${member.user.tag}'dan geri aldınız.`
);
})
.catch((error) => {
console.error("Rol geri alma hatası:", error);
message.reply("Rol geri alırken bir hata oluştu.");
});
} else {
message.reply(`${member.user.tag} zaten ${role.name} rolüne sahip değil.`);
}
});
}
exports.conf = {
enabled: true,
guildOnly: true,
aliases: [],
permLevel: 0
};
exports.help = {
name: "rolkaldır",
description: 'Belirtilen üyenin rollerini alır.',
usage: '!rolkaldır@üye @rol1 @rol2 ...'
};
Discord.js v13 için;
// Komutlar klasörüne atılmalıdır.
// Bu komut Staup tarafından hazırlanmıştır.
const { Permissions } = require('discord.js');
exports.run = (client, message, args) => {
if (!message.member.permissions.has(Permissions.FLAGS.MANAGE_ROLES)) {
return message.reply("Bu komutu kullanma izniniz yok.");
}
const member = message.mentions.members.first();
if (!member) {
return message.reply("Lütfen bir üye etiketleyin.");
}
if (args.length < 3) {
return message.reply("Alınacak rolleri belirtmelisiniz.");
}
const rolesToGrant = message.mentions.roles;
rolesToGrant.forEach((role) => {
if (!member.roles.cache.has(role.id)) {
member.roles
.remove(role)
.then(() => {
message.channel.send(
`Başarıyla ${role.name} rolünü ${member.user.tag}'dan geri aldınız.`
);
})
.catch((error) => {
console.error("Rol geri alma hatası:", error);
message.reply("Rolü geri alırken bir hata oluştu.");
});
} else {
message.reply(`${member.user.tag} zaten ${role.name} rolüne sahip değil.`);
}
});
};
exports.conf = {
enabled: true,
guildOnly: true,
aliases: [],
permLevel: 0
};
exports.help = {
name: "rolkaldır",
description: 'Belirtilen üyenin rollerini alır.',
usage: '!rolkaldır @üye @rol1 @rol2 ...'
};