我是西班牙人,所以我的英语可能有些生疏。我有一个不和谐的bot,其命令禁止一个成员,并向其发送已被禁止的服务器的消息,原因等。但是几天前,我意识到我的bot没有发送消息,但是我没有更改自上一个稳定版本以来的代码,该僵尸程序将邮件发送到了该版本。当我删除禁止用户(message.guild.ban(mentioned, {reason: reason});
)的行时,漫游器会毫无错误地发送消息。您在命令代码下方有, and here you have the error that displays the command prompt.
module.exports = {
name: 'condenar',
description: "Comando principal del verdugo que avisa al condenado. Se suele usar antes del v!ban",
execute(message, args){
if (message.member.roles.find("name", "Monarca")){
const Discord = require('discord.js');
var embedColor = '#ff0000'
const moment = require("moment");
var missingPermissionsEmbed = new Discord.RichEmbed()
.setColor(embedColor)
.setAuthor(message.author.username, message.author.avatarURL)
.setTitle('Permisos insuficientes!')
.setDescription('Necesitas el permiso `MANAGE_MESSAGES` para usar este comando!')
.setTimestamp();
var missingArgsEmbed = new Discord.RichEmbed()
.setColor(embedColor)
.setAuthor(message.author.username, message.author.avatarURL)
.setTitle('Argumentos insuficientes!')
.setDescription('Uso: v!condenar <@User> <Motivo>')
.setTimestamp();
if(!message.member.hasPermission('MANAGE_MESSAGES')) return message.channel.send(missingPermissionsEmbed);
let mentioned = message.mentions.users.first();
if (mentioned.id == 615199347398672392) return message.channel.send('No ahorcare a mi padre.');
if(!mentioned) return message.channel.send(missingArgsEmbed);
let reason = args.slice(1).join(' ')
if(!reason) return message.channe.send(missingArgsEmbed);
var ahorcNumber = Math.random();
var ahorcEmbed = new Discord.RichEmbed()
.setColor(embedColor)
.setDescription(`ID del mensaje: ${message.id}`)
.setTitle(`**Ahorcamiento ${message.guild.name}**`)
.addField('Ahorcado por:', message.author.tag)
.addField('Motivo:', reason)
.addField('ID del ahorcamiento:', `**${ahorcNumber}** *necesitaras este numero para ver la info del ahorcamiento mas adelante.`)
.attachFiles(['./img/ahorcado.gif'])
.setFooter(`En: ${moment().format("dddd, MMMM Do YYYY, h:mm A", Date.now())}`)
.setTimestamp();
mentioned.send(ahorcEmbed);
message.channel.send(ahorcEmbed);
message.guild.ban(mentioned, {reason: reason});
var dir = `./files/${message.guild.id}`;
var fs = require('fs');
if (!fs.existsSync(dir)){
fs.mkdirSync(dir, function(err, result) {
if(err) console.log('error', err);
});
fs.mkdirSync(`${dir}/warns`, function(err, result) {
if(err) console.log('error', err);
});
fs.mkdirSync(`${dir}/ahorcamientos`, function(err, result) {
if(err) console.log('error', err);
});
};
fs.mkdirSync(`${dir}/ahorcamientos/${ahorcNumber}`);
fs.writeFile(`${dir}/ahorcamientos/${ahorcNumber}/ahorcado.txt`, `${mentioned.username}(${mentioned.id})`, 'utf8', function(err, result) {
if(err) console.log('error', err);
});
fs.writeFile(`${dir}/ahorcamientos/${ahorcNumber}/Author.txt`, `${message.author.username}(${message.author.id})`, 'utf8', function(err, result) {
if(err) console.log('error', err);
});
fs.writeFile(`${dir}/ahorcamientos/${ahorcNumber}/Motivo.txt`, `${reason}`, 'utf8', function(err, result) {
if(err) console.log('error', err);
});
if (!fs.existsSync(`${dir}/ahorcamientos/${mentioned.id}.txt`)){
fs.writeFile(`${dir}/ahorcamientos/${mentioned.id}.txt`, 1, 'utf8', function(err, result) {
if(err) console.log('error', err);
});
}else{
fs.readFile(`${dir}/ahorcamientos/${mentioned.id}.txt`, 'utf8', function(err, data) {
var x = +data;
var y = 1;
var z = x + y;
fs.writeFile(`${dir}/ahorcamientos/${mentioned.id}.txt`, `${z}`, 'utf8', function(err, result) {
if(err) console.log('error', err);
});
});
};
}else{
message.channel.send('Tienes que tener el rol `Monarca` para poder usar este comando');
};
}};
答案 0 :(得分:0)
答案很简单,可能不允许用户在DM中向他们发送消息:)
您在这里遇到错误,在n
中缺少channel
:
return message.channe.send(missingArgsEmbed);
答案 1 :(得分:0)
我的测试帐户的机密性设置存在问题。谢谢大家。