静音的前缀是啥

Posted

技术标签:

【中文标题】静音的前缀是啥【英文标题】:What's the prefix for mute静音的前缀是什么 【发布时间】:2021-01-06 16:20:40 【问题描述】:

我的机器人有问题。不能静音工作。帮助?找不到任何前缀,也不知道在哪里添加或如何格式化。我在下面链接了大部分代码。反垃圾邮件和踢/禁止工作。任何帮助的编码新手都会很好。提示如何为所有代码转发设置通用前缀?角色被命名为静音,机器人拥有它需要踢的所有前提

const fs = require('fs');
module.exports = class mute 
    constructor()
        this.name = 'mute',
        this.alias = ['tempmute'],
        this.usage = 'mute';
    

    run(bot, message, args)
        let member = message.mentions.members.first();

        var command = args[0];
        var mentioned = args[1];

        var days = parseInt(args[3]);
        var hours = parseInt(args[4]);
        var seconds = parseInt(args[5]);

        if (message.member.hasPermission('MANAGE_ROLES')) 

        let muterole = message.guild.roles.find(role => role.name === "Muted");

        if (!message.guild) 
        if (message.guild.id === '505872328538718233') 
            let memberrole = message.guild.roles.find("name", "Member");
            member.removeRole(memberrole);

        

        let usermsg = new Discord.RichEmbed();

        usermsg.setTitle('You have been Muted.');
        usermsg.setColor('76b3fc');
        usermsg.setFooter('Please do not attempt to bypass');
        usermsg.addField('Muted by:',
        `<@$message.author.id>`);
        
        let mutedmsg = new Discord.RichEmbed();
    
        mutedmsg.setTitle('User has been Muted Successfully');
        mutedmsg.setColor('76b3fc');
        mutedmsg.setDescription(`User muted: $mentioned\nMuted by: <@$message.author.id>\nReason: $input`);
        mutedmsg.setFooter('This mute has been logged.');

        if (message.content === `$command`) 
            return message.channel.send('You did not provide a member to mute.');
        
        
        if (message.content === `$command $mentioned`) 
        return message.channel.send('Please input a reason for the mute.');
        

        if (message.guild.roles.find(role => role.name)) 

        message.member.addRole(muterole);

            if (message.content.includes (`$daysd`)) 
                message.channel.send(mutedmsg);
            setTimeout(() => 
                member.removeRole(muterole);
                usermsg.addField('Punishment Time:',
                 `$hours Seconds`);
            , `$args[2] * 86400`);
        

            if (message.content.includes (`$hoursh`)) 
                message.channel.send(mutedmsg);
            setTimeout(() => 
                member.removeRole(muterole);
                usermsg.addField('Punishment Time:',
                 `$hours Seconds`);
            , `$args[3] * 3600`);
        

            if (message.content.includes (`$secondss`)) 
                message.channel.send(mutedmsg);
            setTimeout(() => 
                member.removeRole(muterole);
                usermsg.addField('Punishment Time:',
                 `$seconds Seconds`);
            , `$args[4] * 1000`);
        

        if (message.content === `$command $mentioned $input`) 
            message.member.addRole(muterole);
            usermsg.addField('Muted for',
            `$input`);
            usermsg.addField('Punishment Time:',
            'Permenant');
            message.channel.send(mutedmsg);
        

        if (message.member.id === `$message.author.id`) 
            return;
        
        if (message.author.id === `$mentioned`) 
            return message.member.send(usermsg);
        
    
        message.channel.send(mutedmsg);
        console.log('===========================');
        console.log(`Member Muted: $mentioned`);
        console.log(`Muted by: $message.author.tag`);
        console.log(`Reason: $input`);
        console.log('===========================');
     else 

        message.channel.send('You do not have a `Muted` Role, This command won\'t work.');
    

     else 

        message.reply('You do not have permission to do this.');

    

let jsonlogs = JSON.parse(fs.writeFileSync("./storages/mutelogs.json"));

if (!jsonlogs[message.guild.id])
    jsonlogs[message.guild.id] = 
        mutedby: `$message.author.tag`,
        user: `$mentioned`,
        reason: `$input`,
        days: `$days`,
        hours: `$hours`,
        seconds: `$seconds`,
    ;

    
;

【问题讨论】:

【参考方案1】:

你似乎有很多,我的意思是很多来自 Discord.js v11 的过时方法。

我强烈建议您安装最新版本的 DJS 并阅读可在此处找到的所有 v12 更改: https://github.com/discordjs/discord.js/releases/tag/12.0.0

一些例子:

Discord.RichEmbed() 不再存在 -> 使用 Discord.MessageEmbed() .addRole() 不再存在 -> 使用 message.member.roles.add() .removeRole() 不再存在 -> 使用 message.member.roles.remove()

【讨论】:

由于机器人还不到一周,我觉得我有 DJS V12,但代码指南已关闭。 您总能在这里找到您需要的所有信息:discord.js.org/#/docs/main/stable/general/welcome,我还强烈建议您在 YouTube 上观看“WornOffKeys”,他们有很棒的 v12 教程。

以上是关于静音的前缀是啥的主要内容,如果未能解决你的问题,请参考以下文章

[[安装前缀] 是啥意思?

NS前缀是啥意思?

在堆栈中 MoveNext 的前缀是啥意思?

Qt资源系统中前缀优于文件系统路径的优势是啥?

这些在 package.json 中使用下划线前缀的属性是啥?

SceneKit 中的“simd”前缀是啥意思?