JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q37574F
  • License MIT

Discord.jsで簡単にページ式ボタンが作ることができる

Package Exports

  • discord-quick-button-page
  • discord-quick-button-page/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (discord-quick-button-page) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

discord-quick-button-page

このモジュールはDiscord.jsv13,14で動作を確認しています (v12,v11はできません)

sample

const {Client,Intents} = require('discord.js'),
  client = new Client({intents:[Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES]}),
  discord_page = require("discord-quick-button-page");
  discord_page.buttonname({next:"次へ",back:"前へ"});
  discord_page.buttonerror({content:"エラーが発生しました",button:"エラー"});
  const button = discord_page.buttonpage({loop:true,content:["1","2","3","4"],id:"HOGE"});

  client
  .on('messageCreate',message => {
  if(message.content == "!page")message.reply({embeds:[{description:button.content}],components:[button.data]});
  })
    .on("interactionCreate",async i=>{
      await i.deferUpdate();
      const getbtn = discord_page.buttonpush({id:"HOGE",interaction:i});
      if(getbtn) i.editReply({embeds:[{description:getbtn.content}],components:[getbtn.data]});
    })
  .login(process.env.token);

sample(簡易)

const {Client,Intents} = require('discord.js'),
  client = new Client({intents:[Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES]}),
  discord_page = require("discord-quick-button-page"),
  button = discord_page.buttonpage({content:["1","2","3","4"],id:"HOGE"});
  client
  .on('messageCreate',message => {
  if(message.content == "!page")message.reply({content:button.content,components:[button.data]});
  })
    .on("interactionCreate",async i=>{
      await i.deferUpdate();
      const getbtn = discord_page.buttonpush({id:"HOGE",interaction:i});
     if(getbtn) i.editReply({content:getbtn.content,components:[getbtn.data]});
    })
  .login("YOURTOKEN");

buttonpage

buttonpage({loop:true,content:["1","2","3","4"],id:"HOGE"});

loop:(boolean) loopするかどうかです 書かない場合はfalseになります

content:arr 表示するコンテンツを決めます 右から左へページが流れていきます

id:好きなID 複数登録する場合IDを変えて使います 書かない場合はエラーが出ます

返り値はcontentが登録した情報のcontentの0番目でdataがボタンの情報です(エラーの場合は登録したエラー又は初期設定のエラーが表示されます) pageが返るようになりました内容はページ数です

buttonpush

buttonpush({id:"HOGE",interaction:取得したinteraction})

id:好きなID setした時と同じIDを使ってください 一致しない場合エラーボタンに切り替わります

interaction:取得したintaraction interactionCreateイベントで取得した情報を入れてください

返り値はcontentが登録した情報のcontentの0番目でdataがボタンの情報です(エラーの場合は登録したエラー又は初期設定のエラーが表示されます) pageが返るようになりました内容はページ数です

buttonname

ボタンの名前が決めれます 決めない場合はnextとbackです

buttonerror

buttonerror({content:"エラーが発生しました",button:"エラー"})

IDが一致しない場合に出します 初期設定はcontent:notcontent,button:NOTINFOです