npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

discord-quick-button-page

v1.0.19

Published

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

Downloads

12

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"),
  jsondata={
    custom_id:"hage",
    disabled: true,
    label: "捨てる",
    style: 1,
    type: 2,
  };
  discord_page.buttonerror({content:"エラーが発生しました",button:"エラー"});
  const button = discord_page.buttonpage({loop:true,content:["1","2","3","4"],id:"HOGE",customid:{next:"hogenext",back:"hogeback"}});
  const button2 = discord_page.buttonpage({content:["a","b","c","d"],id:"test",customid:{next:"testnext",back:"testback"},name:{next:"次へ",back:"前へ"},json:jsondata});
  client
  .on('messageCreate',message => {
  if(message.content == "!page")message.reply({embeds:[{description:button.content}],components:[button.data]});
    if(message.content=="!page2")message.reply({embeds:[{description:button2.content}],components:[button2.data]});
  })
    .on("interactionCreate",async i=>{
      if(i.customId.startsWith("hoge")){
      await i.deferUpdate();
      const getbtn = discord_page.buttonpush({id:"HOGE",interaction:i});
       i.editReply({embeds:[{description:getbtn.content}],components:[getbtn.data]});
      }
      if(i.customId.startsWith("test")){
       await i.deferUpdate();
      const getbtn = discord_page.buttonpush({id:"test",interaction:i,json:jsondata});
       i.editReply({embeds:[{description:getbtn.content+getbtn.page}],components:[getbtn.data]});
      }
    })
  .login("YOURTOKEN");

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",customid:{next:"hogenext",back:"hogeback"},name:{next:"nextpage",back:"backpage"},json:{custom_id:"hage",label:"hoge",style: 1,type:2}});

loop:boolean

loopするかどうかです

書かない場合はfalseになります

content:arr

表示するコンテンツを決めます

右から左へページが流れていきます

id:String

複数登録する場合IDを変えて使います

書かない場合はエラーが出ます

customid

next:String

customId(進むボタン)の設定ができます(しない場合はBURInext)

back:String

customId(戻るボタン)の設定ができます(しない場合はBURIback)

name

ボタンの名前が決められます

next:String

back:String

初期はnextとbackです

高度な設定

json:discord.js-json型

オリジナルのボタンを追加するときに設定します

componentsのなかのjsonを入れてください(自動でpushします)

データ型を見るにはまずDiscord.jsで普通にボタンを作成します

作成したクラス.toJSON()でデータが得られます

記入しない場合は何も起こりません

間違えている場合はDiscord.js側でエラーが出ます

(エラーの場合は登録したエラー又は初期設定のエラーが表示されます)

返り値

content 配列の次のページ数のコンテンツを返します

data ボタンのJSON型のデータを返します

page 現在のページ数を返します

buttonpush

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

id:String

setした時と同じIDを使ってください

一致しない場合エラーボタンに切り替わります

interaction:interaction-class

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

返り値はcontentが登録した情報のcontentの0番目でdataがボタンの情報です

(エラーの場合は登録したエラー又は初期設定のエラーが表示されます) 返り値

content 配列の次のページ数のコンテンツを返します

data ボタンのJSON型のデータを返します

page 現在のページ数を返します

buttonname

.buttonname({next:"次へ",back:"前へ"});

next:String,back:String

ボタンの名前が決めれます

初期設定はnext:next,back:backです

未設定可

返り値

なし

buttonerror

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

content:String,button:String

IDが一致しない場合に出します

初期設定はcontent:notcontent,button:NOTINFOです

未設定可

返り値

なし

.buttoncustomid({next:"hogenext",back:"hogeback"});

customIDを決めれます

注意

customIDは指定のcustomID+現在のページ番号です

初期はBURInextorback+ページ番号

これの活用方法はcustomIDを指定していちいち関数を呼ばないことで処理の軽減を図れます

実行の様子

実行写真