【问题标题】:Don't know how to form a short question so any help would be appreciated不知道如何形成一个简短的问题,所以任何帮助将不胜感激
【发布时间】:2021-08-15 22:27:07
【问题描述】:

所以我做了这个投票命令,没有管理员的人可以进行投票。为了防止垃圾邮件,没有管理员的每个人都有一个验证步骤。但是,当您对民意调查做出反应以验证它时,它仅适用于进行民意调查的人。而不是应该检查它是否不是垃圾邮件的管理员。

因此,当管理员做出反应时,没有任何反应,但当进行投票的人对其做出反应时,它会验证投票并将其发送到主频道。

下面的代码有人可以帮忙! '欣赏它!

 const {Client, Collection, GuildMember, User, MessageEmbed, Message} = require("discord.js");
    const ms = require("ms");
    const delay = (msec) => new Promise((resolve) => setTimeout(resolve, msec));
    module.exports.run = async(client, message, args, user, reaction) => {
    
        var woord = '!poll' 
        var question = args.slice(0).join(' ') 
        var poll = new MessageEmbed()
            .setTitle(`${message.author.username} wil een poll maken.`)
            .setDescription(question)
            .setColor('#eb8dd8')
            .setFooter(`Poll gemaakt door: `+ message.author.username)
    
        var success = new MessageEmbed()
            .setDescription(question)
            .setColor('#eb8dd8')
            .setFooter("Poll started door: "+ message.author.username)
    
            
    
        if(message.content.includes(woord)) {
            message.delete({timeout:0}) 
        }
    
        if(!message.member.roles.cache.some(r => r.name === 'Barman')) {
            if(message.channel.name.includes("????-poll")) {
                if(args[0]) {
                    message.delete()
                    message.guild.channels.create(message.author.username, { permissionOverwrites:[
                        {
                            deny: 'VIEW_CHANNEL',
                            id: message.guild.id
                        },
                        {
                            allow: 'VIEW_CHANNEL',
                            id: message.author.id
                        },
                    ],
                }).then(channel => {
                    channel.send(poll).then(poll => {
                        poll.react('✅')
                        .then(() => poll.react('❌'));
                    })
                })
    
                } else {
                    message.delete()
                }
            }
        } else {
            var pollChannel = client.channels.cache.get('876531134702448701')
            pollChannel.send(success).then(success => {
                success.react('✅')
                .then(() => success.react('❌'))
            })
        }
        
    
        client.on('messageReactionAdd', (reaction, user) => {
            const deleteChannel = message.guild.channels.cache.find(channel => channel.name.toLowerCase() === user.username);
            var pollChannel = client.channels.cache.get('876531134702448701')
            if(reaction.emoji.name === '✅') {
                if(message.guild.channels.cache.find(channel => channel.name.toLowerCase() === user.username)) {
                    deleteChannel.delete()
                    .then(channel => {
                        pollChannel.send(success).then(success =>{
                            success.react('✅')
                            .then(() => success.react('❌'))
                        })
                    })
                    
    
                }
            } if(reaction.emoji.name === '❌') {
                if(message.guild.channels.cache.find(channel => channel.name.toLowerCase() === user.username)) {
                    deleteChannel.delete()
                }
            }
        })
    }
        
    
    
    module.exports.help = {
        name: "poll"
    }

【问题讨论】:

    标签: node.js discord.js


    【解决方案1】:

    在你的函数开始时,你可以这样做:

    const questions = new Collection();
    questions.set("What is the color of healthy grass?", "green");
    questions.set("How many vowels are there in these letters: apple", "2");
    const chosen = questions.randomKey()
    await message.channel.send(`Please answer the question. This is to prevent spam. Make sure your spelling is correct. You have 30 seconds —> ${chosen}`)
    try {
      await message.channel.awaitMessages((m) => m.author.id === message.author.id && m.content.toLowerCase() === questions.get(chosen), {
        time: 30000, 
        max: 1
      })
    } catch(err) { 
      return message.channel.send("You ran out of time to answer correctly!")
    }
    //code to make poll
    

    您的 awaitMessages 语法在 v13 上可能有所不同。你也可以替换我的问题,想加多少就加多少!

    【讨论】:

      猜你喜欢
      • 2021-05-11
      • 1970-01-01
      • 1970-01-01
      • 2019-06-24
      • 2021-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多