我目前正在编写一个discord.js不和谐机器人,我已经设法完成了基本的踢,班
这是我的静音命令
if(command === "mute") {
let reason = args.slice(1).join(' ');
let user = message.mentions.users.first();
let logchannel = message.guild.channels.find('name', 'cgr420-logs');
if (!logchannel) return message.reply('I cannot find a logs channel');
if (!message.member.hasPermission("MUTE_MEMBERS")) return
message.reply(":no_entry_sign: **Error:** You don't have the **Mute Members**
permission!");
if (reason.length < 1) return message.reply('You must supply a reason for the
mute.');
if (message.mentions.users.size < 1) return message.reply('You must mention
someone to mute them.').catch(console.error);
if (!message.guild.member(user).bannable) return
message.reply(`:no_entry_sign: I cannot mute that member`);
message.guild.member(user).ban();
const embed = new Discord.RichEmbed()
.setColor(0xFF0000)
.setTimestamp()
.addField('Action:', 'Mute')
.addField('User:', `${user.username}#${user.discriminator} (${user.id})`)
.addField('Moderator:',
`${message.author.username}#${message.author.discriminator}`)
.addField('Reason', reason);
message.channel.send(`:hammer: Bippity boppity **MUTED**! I\'ve logged the
mute in the logs channel.`)
return client.channels.get(logchannel.id).send({embed});
};
我将感谢任何形式的帮助在正确的方向。
提前谢谢。
const db = require('quick.db');
module.exports = {
config: {
name: "mute",
description: "Mutes a member in the discord!",
usage: "[name | nickname | mention | ID] <reason> (optional)",
},
run: async (bot, message, args) => {
try {
if (!message.member.hasPermission("MANAGE_GUILD")) return message.channel.send("**You Dont Have Permmissions To Mute Someone! - [MANAGE_GUILD]**");
if (!message.guild.me.hasPermission("MANAGE_GUILD")) return message.channel.send("**I Don't Have Permissions To Mute Someone! - [MANAGE_GUILD]**")
if (!args[0]) return message.channel.send("**Please Enter A User To Be Muted!**");
var mutee = message.mentions.members.first() || message.guild.members.cache.get(args[0]) || message.guild.members.cache.find(r => r.user.username.toLowerCase() === args[0].toLocaleLowerCase()) || message.guild.members.cache.find(ro => ro.displayName.toLowerCase() === args[0].toLocaleLowerCase());
if (!mutee) return message.channel.send("**Please Enter A Valid User To Be Muted!**");
if (mutee === message.member) return message.channel.send("**You Cannot Mute Yourself!**")
if (mutee.roles.highest.comparePositionTo(message.guild.me.roles.highest) >= 0) return message.channel.send('**Cannot Mute This User!**')
let reason = args.slice(1).join(" ");
if (mutee.user.bot) return message.channel.send("**Cannot Mute Bots!**");
const userRoles = mutee.roles.cache
.filter(r => r.id !== message.guild.id)
.map(r => r.id)
let muterole;
let dbmute = await db.fetch(`muterole_${message.guild.id}`);
let muteerole = message.guild.roles.cache.find(r => r.name === "muted")
if (!message.guild.roles.cache.has(dbmute)) {
muterole = muteerole
} else {
muterole = message.guild.roles.cache.get(dbmute)
}
if (!muterole) {
try {
muterole = await message.guild.roles.create({
data: {
name: "muted",
color: "#514f48",
permissions: []
}
})
message.guild.channels.cache.forEach(async (channel) => {
await channel.createOverwrite(muterole, {
SEND_MESSAGES: false,
ADD_REACTIONS: false,
SPEAK: false,
CONNECT: false,
})
})
} catch (e) {
console.log(e);
}
};
if (mutee.roles.cache.has(muterole.id)) return message.channel.send("**User Is Already Muted!**")
db.set(`muteeid_${message.guild.id}_${mutee.id}`, userRoles)
try {
mutee.roles.set([muterole.id]).then(() => {
mutee.send(`**Hello, You Have Been Muted In ${message.guild.name} for - ${reason || "No Reason"}`).catch(() => null)
})
} catch {
mutee.roles.set([muterole.id])
}
if (reason) {
const sembed = new MessageEmbed()
.setColor("GREEN")
.setAuthor(message.guild.name, message.guild.iconURL())
.setDescription(`${mutee.user.username} was successfully muted for ${reason}`)
message.channel.send(sembed);
} else {
const sembed2 = new MessageEmbed()
.setColor("GREEN")
.setDescription(`${mutee.user.username} was successfully muted`)
message.channel.send(sembed2);
}
let channel = db.fetch(`modlog_${message.guild.id}`)
if (!channel) return;
let embed = new MessageEmbed()
.setColor('RED')
.setThumbnail(mutee.user.displayAvatarURL({ dynamic: true }))
.setAuthor(`${message.guild.name} Modlogs`, message.guild.iconURL())
.addField("**Moderation**", "mute")
.addField("**Mutee**", mutee.user.username)
.addField("**Moderator**", message.author.username)
.addField("**Reason**", `${reason || "**No Reason**"}`)
.addField("**Date**", message.createdAt.toLocaleString())
.setFooter(message.member.displayName, message.author.displayAvatarURL())
.setTimestamp()
var sChannel = message.guild.channels.cache.get(channel)
if (!sChannel) return;
sChannel.send(embed)
} catch {
return;
}
}
}```
i want for this anyone tell pls
if(command === "unmute") {
let reason = args.slice(1).join(' ');
let user = message.mentions.users.first();
let logchannel = message.guild.channels.find('name', 'cgr420-logs');
let role = message.guild.roles.find('name', 'mute')
//CHANGE THIS ^^
if (!logchannel) return message.reply('I cannot find a logs channel');
if (!message.member.hasPermission("MUTE_MEMBERS")) return
message.reply(":no_entry_sign: **Error:** You don't have the **Mute Members**
permission!");
if (reason.length < 1) return message.reply('You must supply a reason for the mute.');
if (message.mentions.users.size < 1) return message.reply('You must mention
someone to mute them.').catch(console.error);
if (!message.guild.member(user).roles.has(role)) return message.reply(`:no_entry_sign: I cannot unmute that member`);
message.guild.member(user).removeRole(role);
const embed = new Discord.RichEmbed()
.setColor("0xFF0000")
.setTimestamp()
.addField('Action:', 'Unmute')
.addField('User:', `${user.tag} (${user.id})`)
.addField('Moderator:',
`${message.author.tag}`)
.addField('Reason', reason);
message.channel.send(`:hammer: Bippity boppity **UNMUTED**! I\'ve logged the
unmute in the logs channel.`)
return logchannel.send(embed);
};
问题内容: 最近,我一直在询问有关discord.py的大量问题,这就是其中之一。 有时候,有些人向您的不和谐服务器发送垃圾邮件,但踢或禁止它们似乎太苛刻了。我想到了一个命令,该命令将在给定的时间内删除通道上的所有新消息。 到目前为止,我的代码是: 我这一节中的代码是: 所有使用的变量都在bot的顶部预先定义。 我的问题是,该漫游器会删除其有权访问的所有频道中的所有新消息。我尝试放入该部分,但这使
非常好的一天, 任何帮助都很感激。提前谢了。
我正在为我的服务器编写Discord bot代码。我想为我的机器人添加一个命令,该命令将清除一个文本通道,并且只允许具有所有者、管理员、版主角色的人。 在代码中,它是have
但当我在命令行上运行该命令时,它会抛出以下错误: 我可以成功地运行其他的adb命令,我不知道aapt命令有什么问题。另外,我正在Windows7环境下进行开发。
当我使用命令列出所有分支时,我会看到的输出。 命令应该显示分支列表,就像对文件所做的那样。 这是我得到的输出: 如何获得git分支的默认行为?是什么导致分页输出? 我将ZSH与(其中Git没有任何内容)一起使用,我的如下所示:
问题内容: 我正在写以下命令 我怎样才能将此命令限制为仅管理员?我试着看,它说。我如何检查给定的用户是否是? 问题答案: 有两种方法:通过使用的角色白名单 或经许可使用 这两个装饰器都是Checks,如果它们失败,将引发您的一些子类供您选择处理。