Skip to content

mome0320/koreanbots.js

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

69 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Koreanbots - JS SDK

Version Documentation Maintenance License: MIT Downloads eslint.yml

JS SDK for Koreanbots

์„ค์น˜

npm install koreanbots

์˜ต์…˜

Koreanbots.MyBot

์˜ต์…˜ ํƒ€์ž… ํ•„์ˆ˜ ๊ธฐ๋ณธ๊ฐ’ ์„ค๋ช…
token String O - Koreanbots์˜ ํ† ํฐ
options.hideToken Boolean false ์™ธ๋ถ€๋กœ ์œ ์ถœ๋ ์ˆ˜ ์žˆ๋Š” this.token์„ ๊ฐ€๋ฆฝ๋‹ˆ๋‹ค.
options.noWarning Boolean false ๋ชจ๋“ˆ์˜ ๊ฒฝ๊ณ  ์•Œ๋ฆผ์„ ๋•๋‹ˆ๋‹ค
options.avoidRateLimit Boolean true ๋ ˆ์ดํŠธ๋ฆฌ๋ฐ‹์„ ์ตœ๋Œ€ํ•œ ํ”ผํ•ฉ๋‹ˆ๋‹ค
options.autoFlush Number 100 ์บ์‹œ์— ์ €์žฅ๋œ ๋ฐ์ดํ„ฐ ์ˆ˜๊ฐ€ options.autoFlush๋ฅผ ๋„˜์„์‹œ ์บ์‹œ๋ฅผ ์ดˆ๊ธฐํ™”ํ•ฉ๋‹ˆ๋‹ค. (์ž๋™ ์บ์‹œ ๊ด€๋ฆฌ)
options.autoFlushInterval Number 3600000 options.autoFlushInterval(๋ฐ€๋ฆฌ์ดˆ)๋งˆ๋‹ค ์บ์‹œ๋ฅผ ๊ด€๋ฆฌํ•ฉ๋‹ˆ๋‹ค

Koreanbots.Bots

  • ์ฃผ์˜: Bots๋Š” ์บ์‹œ๋ฅผ ์ž์ฃผ ํ™œ์šฉํ•ฉ๋‹ˆ๋‹ค. ์ด๋Š” ๊ณง ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ๋Ÿ‰์œผ๋กœ ์ง๊ฒฐ๋˜๋ฉฐ autoFlush๋กœ ์‹œ์ž‘ํ•˜๋Š” ์˜ต์…˜๋“ค์„ ์ž˜ ์„ค์ •ํ•ด์ฃผ์„ธ์š”.
์˜ต์…˜ ํƒ€์ž… ํ•„์ˆ˜ ๊ธฐ๋ณธ๊ฐ’ ์„ค๋ช…
options.noWarning Boolean false ๋ชจ๋“ˆ์˜ ๊ฒฝ๊ณ  ์•Œ๋ฆผ์„ ๋•๋‹ˆ๋‹ค
options.avoidRateLimit Boolean true ๋ ˆ์ดํŠธ๋ฆฌ๋ฐ‹์„ ์ตœ๋Œ€ํ•œ ํ”ผํ•ฉ๋‹ˆ๋‹ค
options.autoFlush Number 100 ์บ์‹œ์— ์ €์žฅ๋œ ๋ฐ์ดํ„ฐ ์ˆ˜๊ฐ€ options.autoFlush๋ฅผ ๋„˜์„์‹œ ์บ์‹œ๋ฅผ ์ดˆ๊ธฐํ™”ํ•ฉ๋‹ˆ๋‹ค. (์ž๋™ ์บ์‹œ ๊ด€๋ฆฌ)
options.autoFlushInterval Number 3600000 options.autoFlushInterval(๋ฐ€๋ฆฌ์ดˆ)๋งˆ๋‹ค ์บ์‹œ๋ฅผ ๊ด€๋ฆฌํ•ฉ๋‹ˆ๋‹ค

Koreanbots.Widgets

์˜ต์…˜ ํƒ€์ž… ํ•„์ˆ˜ ๊ธฐ๋ณธ๊ฐ’ ์„ค๋ช…
options.autoFlush Number 100 ์บ์‹œ์— ์ €์žฅ๋œ ๋ฐ์ดํ„ฐ ์ˆ˜๊ฐ€ options.autoFlush๋ฅผ ๋„˜์„์‹œ ์บ์‹œ๋ฅผ ์ดˆ๊ธฐํ™”ํ•ฉ๋‹ˆ๋‹ค. (์ž๋™ ์บ์‹œ ๊ด€๋ฆฌ)
options.autoFlushInterval Number 3600000 options.autoFlushInterval(๋ฐ€๋ฆฌ์ดˆ)๋งˆ๋‹ค ์บ์‹œ๋ฅผ ๊ด€๋ฆฌํ•ฉ๋‹ˆ๋‹ค

์ˆ˜๋™ ๋ฉ”๋ชจ๋ฆฌ(์บ์‹œ) ๊ด€๋ฆฌ

const { SearchCache } = require("koreanbots")._cache.Bots

if(SearchCache.size >= 100) SearchCache.clear()

์œ„์ ฏ

const { Widgets } = require("koreanbots")
const widget = new Widgets()
const { MessageAttachment } = require("discord.js")

widget.getVoteWidget(client.user.id, "jpeg").then(w => {
    let wg = new MessageAttachment(w)

    message.channel.send(wg)
}).catch(er => { throw er })

ํ…Œ์ŠคํŠธํ•˜๊ธฐ

  • discord.js : ์ž๋™ ์—…๋ฐ์ดํŠธ

์ฃผ์˜: ์ด KoreanbotsClient๋Š” discord.js v11,12์—์„œ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค.

const { KoreanbotsClient } = require("koreanbots")
const client = new KoreanbotsClient({
    koreanbotsToken: "ํ† ํฐ",
    koreanbotsOptions: {
        interval: 600000 //10๋ถ„๋งˆ๋‹ค ์„œ๋ฒ„ ์ˆ˜๋ฅผ ์—…๋ฐ์ดํŠธํ•ฉ๋‹ˆ๋‹ค. (๊ธฐ๋ณธ๊ฐ’ 30๋ถ„)
    }
})

client.on("ready", () => console.log(`${client.user.tag}๋กœ ๋กœ๊ทธ์ธํ•˜์˜€์Šต๋‹ˆ๋‹ค.`))

client.login("ํ† ํฐ")

process.on("SIGINT", () => {
    client.destroy()
    process.exit()
})
  • discord.js v12 : ์ˆ˜๋™ ์—…๋ฐ์ดํŠธ
const { MyBot } = require("koreanbots")
const Bot = new MyBot("Koreanbots ํ† ํฐ")

let update = count => Bot.update(count) 
    .then(res => console.log("์„œ๋ฒ„ ์ˆ˜๋ฅผ ์ •์ƒ์ ์œผ๋กœ ์—…๋ฐ์ดํŠธํ•˜์˜€์Šต๋‹ˆ๋‹ค!\n๋ฐ˜ํ™˜๋œ ์ •๋ณด:" + JSON.stringify(res)))
    .catch(console.error)

client.on("ready", () => {
    console.log(`${client.user.tag}๋กœ ๋กœ๊ทธ์ธํ•˜์˜€์Šต๋‹ˆ๋‹ค.`)

    update(client.guilds.size) // ์ค€๋น„ ์ƒํƒœ๋ฅผ ์‹œ์ž‘ํ•  ๋•Œ, ์ตœ์ดˆ๋กœ ์—…๋ฐ์ดํŠธํ•ฉ๋‹ˆ๋‹ค.
    setInterval(() => update(client.guilds.cache.size), 600000) // 10๋ถ„๋งˆ๋‹ค ์„œ๋ฒ„ ์ˆ˜๋ฅผ ์—…๋ฐ์ดํŠธํ•ฉ๋‹ˆ๋‹ค.
})

client.login("ํ† ํฐ")
  • discord.js v11 : ์ˆ˜๋™ ์—…๋ฐ์ดํŠธ
const { MyBot } = require("koreanbots")
const Bot = new MyBot("Koreanbots ํ† ํฐ")

let update = count => Bot.update(count) 
    .then(res => console.log("์„œ๋ฒ„ ์ˆ˜๋ฅผ ์ •์ƒ์ ์œผ๋กœ ์—…๋ฐ์ดํŠธํ•˜์˜€์Šต๋‹ˆ๋‹ค!\n๋ฐ˜ํ™˜๋œ ์ •๋ณด:" + JSON.stringify(res)))
    .catch(console.error)

client.on("ready", () => {
    console.log(`${client.user.tag}๋กœ ๋กœ๊ทธ์ธํ•˜์˜€์Šต๋‹ˆ๋‹ค.`)

    update(client.guilds.size) // ์ค€๋น„ ์ƒํƒœ๋ฅผ ์‹œ์ž‘ํ•  ๋•Œ, ์ตœ์ดˆ๋กœ ์—…๋ฐ์ดํŠธํ•ฉ๋‹ˆ๋‹ค.
    setInterval(() => update(client.guilds.size), 600000) // 10๋ถ„๋งˆ๋‹ค ์„œ๋ฒ„ ์ˆ˜๋ฅผ ์—…๋ฐ์ดํŠธํ•ฉ๋‹ˆ๋‹ค.
})

client.login("ํ† ํฐ")
  • ์•„์ด๋””๋กœ ๋ด‡ ์ •๋ณด ๊ฐ€์ ธ์˜ค๊ธฐ (/bots/get/:id)
const koreanbots = require("koreanbots");
const Bots = new koreanbots.Bots()

Bots.get("653534001742741552")
    .then(r => console.log(r)) // ๋ฐ˜ํ™˜๋˜๋Š” ๋ฐ์ดํ„ฐ๋Š” ์˜† ๋งํฌ๋ฅผ ์ฐธ๊ณ ํ•ด์ฃผ์„ธ์š”: https://koreanbots.dev/js-sdk/interfaces/_types_.getbyid.html
    .catch(e => console.error(e))

Author

๐Ÿ‘ค zero734kr

๐Ÿค ๋„์›€์ฃผ๊ธฐ

์ด์Šˆ์™€ PR์€ ๋ชจ๋‘ ํ™˜์˜์ž…๋‹ˆ๋‹ค!
๋ฌด์–ธ๊ฐ€ ๋ฌธ์ œ๊ฐ€ ์ƒ๊ฒผ๋‹ค๋ฉด ์ด์Šˆ ํŽ˜์ด์ง€ ๋˜๋Š” koreanbots ํ†ตํ•ฉ ์ด์Šˆ ํŽ˜์ด์ง€์— ์ €๋ฅผ ์–ธ๊ธ‰ํ•˜์—ฌ ์•Œ๋ ค์ฃผ์„ธ์š”! (์˜ˆ์‹œ: @zero734kr, js sdk ๋ฒ„๊ทธ์ž…๋‹ˆ๋‹ค.)
์ฝ”๋“œ ์ˆ˜์ • ์š”์ฒญ์€ PR ํŽ˜์ด์ง€์— ์˜ฌ๋ ค์ฃผ์„ธ์š”.

์„œํฌํŠธ

๋งŒ์•ฝ ์ด ๋ชจ๋“ˆ์ด ๋„์›€์ด ๋˜์—ˆ๋‹ค๋ฉด โญ๏ธ๋ฅผ ๋ˆŒ๋Ÿฌ์ฃผ์„ธ์š”!

๐Ÿ“ ๋ผ์ด์„ผ์Šค

Copyright ยฉ 2020 zero734kr.
This project is MIT licensed.


This README was generated with โค๏ธ by readme-md-generator

About

Official JS SDK for Koreanbots

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 98.8%
  • TypeScript 1.2%