質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Discord

Discordは、ゲーマー向けのボイスチャットアプリです。チャット・通話がブラウザ上で利用可能で、個人専用サーバーも開設できます。通話中でも音楽を流したり、PC画面を共有できるなど多機能な点が特徴です。

Node.js

Node.jsとはGoogleのV8 JavaScriptエンジンを使用しているサーバーサイドのイベント駆動型プログラムです。

JavaScript

JavaScriptは、プログラミング言語のひとつです。ネットスケープコミュニケーションズで開発されました。 開発当初はLiveScriptと呼ばれていましたが、業務提携していたサン・マイクロシステムズが開発したJavaが脚光を浴びていたことから、JavaScriptと改名されました。 動きのあるWebページを作ることを目的に開発されたもので、主要なWebブラウザのほとんどに搭載されています。

Q&A

1回答

2152閲覧

Discord.jsチャンネルの権限を指定したい

_came_kame_

総合スコア23

Discord

Discordは、ゲーマー向けのボイスチャットアプリです。チャット・通話がブラウザ上で利用可能で、個人専用サーバーも開設できます。通話中でも音楽を流したり、PC画面を共有できるなど多機能な点が特徴です。

Node.js

Node.jsとはGoogleのV8 JavaScriptエンジンを使用しているサーバーサイドのイベント駆動型プログラムです。

JavaScript

JavaScriptは、プログラミング言語のひとつです。ネットスケープコミュニケーションズで開発されました。 開発当初はLiveScriptと呼ばれていましたが、業務提携していたサン・マイクロシステムズが開発したJavaが脚光を浴びていたことから、JavaScriptと改名されました。 動きのあるWebページを作ることを目的に開発されたもので、主要なWebブラウザのほとんどに搭載されています。

0グッド

0クリップ

投稿2021/07/12 12:18

前提・実現したいこと

ボタンを押して作られたチャンネルの権限を追加したいのですが
エラーが出て追加されません(多分コードのせい(そのコードが分からない))

発生している問題・エラーメッセージ

(node:9348) UnhandledPromiseRejectionWarning: TypeError [INVALID_TYPE]: Supplied parameter is not a User nor a Role. at Function.resolve (/rbd/pnpm-volume/ce4ee5fc-5e9a-42f2-a0a4-5fd3539a9378/node_modules/.registry.npmjs.org/discord.js/12.5.3/node_modules/discord.js/src/structures/PermissionOverwrites.js:177:28) at /rbd/pnpm-volume/ce4ee5fc-5e9a-42f2-a0a4-5fd3539a9378/node_modules/.registry.npmjs.org/discord.js/12.5.3/node_modules/discord.js/src/managers/GuildChannelManager.js:109:81 at Array.map (<anonymous>) at GuildChannelManager.create (/rbd/pnpm-volume/ce4ee5fc-5e9a-42f2-a0a4-5fd3539a9378/node_modules/.registry.npmjs.org/discord.js/12.5.3/node_modules/discord.js/src/managers/GuildChannelManager.js:109:51) Client.<anonymous> (/app/index.js:89:27) at processTicksAndRejections (internal/process/task_queues.js:88:5) (node:9348) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2) (node:9348) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

該当のソースコード

const prefix = '=' const disbtn = require("discord.js-buttons")(client); client.on("message", async message => { if (!message.content.startsWith(prefix)) return; const args = message.content .slice(prefix.length) .trim() .split(/ +/g); const command = args.shift().toLowerCase(); if (command === "shin") { const button = new disbtn.MessageButton() .setID("shin") .setStyle("green") .setLabel("ボタンの言葉"); message.channel.send({ embed: { title: "埋め込みのタイトル", description: "埋め込みの説明", color: 0xffa500 }, buttons: [button] }); } }); client.on("clickButton", async button => { try { if (button.id === "shin") { await button.think(true); const member = client.guilds.cache.get(button.guild.id).member(button.clicker.user.id); const shin = await button.guild.channels.create('チャンネル名', { parent: button.channel.parent }) button.guild.channels.create(shin, { type: "text", permissionOverwrites: [ { id: 'ロールID', allow: ['VIEW_CHANNEL'] }, { id: '管理者のID', allow: ['VIEW_CHANNEL'] }, { id: 'サーバーID', deny: ['VIEW_CHANNEL'] } ] }) .then((channel) => { const categoryID = 'カテゴリーのID'; channel.setParent(categoryID); }) button.reply.edit("チャンネルを作成しました"); } } catch (e) { // log any errors that come if (e == "DiscordAPIError: Unknown Message") return; console.log(`エラー ${e}`); } });

試したこと

上のやつ

補足情報(FW/ツールのバージョンなど)

discord.js 12.5.3
discord.js-buttons 1.0.0

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

Waki285

2021/07/22 04:13

BAの選択をお願いします。
guest

回答1

0

チャンネルの名前に、TextChannelクラスを代入してしまっています。

js

1const prefix = '=' 2const disbtn = require("discord.js-buttons")(client); 3client.on("message", async message => { 4 if (!message.content.startsWith(prefix)) return; 5 const args = message.content 6 .slice(prefix.length) 7 .trim() 8 .split(/ +/g); 9 const command = args.shift().toLowerCase(); 10 if (command === "shin") { 11 const button = new disbtn.MessageButton() 12 .setID("shin") 13 .setStyle("green") 14 .setLabel("ボタンの言葉"); 15 message.channel.send({ 16 embed: { 17 title: "埋め込みのタイトル", 18 description: 19 "埋め込みの説明", 20 color: 0xffa500 21 }, 22 buttons: [button] 23 }); 24 } 25}); 26client.on("clickButton", async button => { 27 try { 28 if (button.id === "shin") { 29 await button.think(true); 30 const member = client.guilds.cache.get(button.guild.id).member(button.clicker.user.id); 31 button.guild.channels.create("チャンネル名", { 32 type: "text", 33 parent: button.channel.parent, 34 permissionOverwrites: [ 35 { 36 id: 'ロールID', 37 allow: ['VIEW_CHANNEL'] 38 }, 39 { 40 id: '管理者のID', 41 allow: ['VIEW_CHANNEL'] 42 }, 43 { 44 id: 'サーバーID', 45 deny: ['VIEW_CHANNEL'] 46 } 47 ] 48 }) 49 .then((channel) => { 50 const categoryID = 'カテゴリーのID'; 51 channel.setParent(categoryID); 52 }) 53 button.reply.edit("チャンネルを作成しました"); 54 } 55 } catch (e) { 56 // log any errors that come 57 if (e == "DiscordAPIError: Unknown Message") return; 58 console.log(`エラー ${e}`); 59 } 60});

おそらくこれで解決します。

投稿2021/07/15 23:36

Waki285

総合スコア2014

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

_came_kame_

2021/07/23 02:17 編集

Unknown interaction が出ました... IDもあってるはずです
Waki285

2021/07/23 11:41

hmmmm... こちら側ではうまくいったので、pingの問題でしょうか? (interactionは3秒以内に応答しないとtokenが失効します)
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問