第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

鎖定命令 Discord.js

鎖定命令 Discord.js

嗶嗶one 2023-05-19 15:03:39
我最近為 discord.js 做了一個(gè)鎖定命令。但是,每當(dāng)我運(yùn)行命令時(shí),我都會(huì)收到錯(cuò)誤消息。這是代碼:module.exports = {    name: "lock",    description: "Lock",    async run(client, message, args) {        if (!message.member.hasPermission("KICK_MEMBERS")) return message.channel.send('You can\'t use that!')        function lock(message) {            let channel = message.channel;            const Guild = client.guilds.cache.get("751424392420130907");            if (!Guild) return console.error("Couldn't find the guild.");            const Role = Guild.roles.cache.find(role => role.name == "Verified");            channel.overwritePermissions(                Role, {                'SEND_MESSAGES': false            },                'Competitive has Ended'            )        }        lock(message)        message.channel.send('Channel Locked')    }}正如我之前提到的,每當(dāng)我運(yùn)行此命令時(shí),我都會(huì)收到以下錯(cuò)誤:(node:1354) UnhandledPromiseRejectionWarning: TypeError [INVALID_TYPE]: Supplied overwrites is not an Array or Collection of Permission Overwrites.    at TextChannel.overwritePermissions (/home/runner/SweatyBeautifulHelpfulWorker/node_modules/discord.js/src/structures/GuildChannel.js:208:9)    at lock (/home/runner/SweatyBeautifulHelpfulWorker/commands/lock.js:14:11)    at Object.run (/home/runner/SweatyBeautifulHelpfulWorker/commands/lock.js:21:1)    at Client.<anonymous> (/home/runner/SweatyBeautifulHelpfulWorker/index.js:77:42)    at Client.emit (events.js:327:22)    at Client.EventEmitter.emit (domain.js:483:12)    at MessageCreateAction.handle (/home/runner/SweatyBeautifulHelpfulWorker/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)    at Object.module.exports [as MESSAGE_CREATE] (/home/runner/SweatyBeautifulHelpfulWorker/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
查看完整描述

5 回答

?
白衣染霜花

TA貢獻(xiàn)1796條經(jīng)驗(yàn) 獲得超10個(gè)贊

你應(yīng)該這樣做,你的代碼看起來很長:


 if (!message.member.roles.cache.some(role => role.name === 'Moderator')) return;

 message.channel.updateOverwrite(message.channel.guild.roles.everyone, { SEND_MESSAGES: false })

 message.channel.send(`Successfully locked **${message.channel.name}**`)

從你的角色中替換message.channel.guild.roles.everyone。


查看完整回答
反對(duì) 回復(fù) 2023-05-19
?
桃花長相依

TA貢獻(xiàn)1860條經(jīng)驗(yàn) 獲得超8個(gè)贊

這不是你如何更新權(quán)限而不是這個(gè):


channel.overwritePermissions(

? ? ? ? ? ? Role, {

? ? ? ? ? ? 'SEND_MESSAGES': false

? ? ? ? },

? ? ? ? ? ? 'Competitive has Ended'

? ? ? ? )

用這個(gè):


channel.overwritePermissions([

? ? ? ? {

? ? ? ? id: roleId,

? ? ? ? deny: ['SEND_MESSAGES']

? ? ? ? }]

? ? ? ? ,'Competitive has Ended'

? ? )


查看完整回答
反對(duì) 回復(fù) 2023-05-19
?
三國紛爭(zhēng)

TA貢獻(xiàn)1804條經(jīng)驗(yàn) 獲得超7個(gè)贊

下面這段代碼可能對(duì)你有幫助


channel.overwritePermissions(

    [

        {

            id: roleId,

            deny: [

                'SEND_MESSAGES'

            ]

        }

    ]

        , 'Mark my question'

)```


查看完整回答
反對(duì) 回復(fù) 2023-05-19
?
慕無忌1623718

TA貢獻(xiàn)1744條經(jīng)驗(yàn) 獲得超4個(gè)贊

你也應(yīng)該使用updateOverwrite而不是overwritePermissions。


例子:


module.exports = {

    name: "lock",

    description: "Lock",


    run(client, message, args) {

       const targetChannel = message.mentions.channels.first() || message.channel;


        // Guild ID is the same as the everyone role ID

        const everyoneID = message.guild.id;


        targetChannel.updateOverwrite(everyoneID, {

            SEND_MESSAGES: false,

        });


        targetChannel.send(`**${targetChannel.name}** has been locked :lock:`);

    }

}

也不需要它是異步函數(shù),因?yàn)槟鷽]有在代碼中使用 await 。



查看完整回答
反對(duì) 回復(fù) 2023-05-19
?
一只斗牛犬

TA貢獻(xiàn)1784條經(jīng)驗(yàn) 獲得超2個(gè)贊

您只需調(diào)用以下行即可刪除當(dāng)前頻道的發(fā)送權(quán)限:


const Role = guild.roles.find("name", "Verified ");


message.channel.overwritePermissions(role,{ 'SEND_MESSAGES': false })

如果你想制作解鎖頻道命令,只需在命令下添加:


const Role = guild.roles.find("name", "Verified ");


message.channel.overwritePermissions(role,{ 'SEND_MESSAGES': true})


查看完整回答
反對(duì) 回復(fù) 2023-05-19
  • 5 回答
  • 0 關(guān)注
  • 310 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)