JS SDK for Koreanbots
๐ ํํ์ด์ง
npm install koreanbots
์ต์ | ํ์ | ํ์ | ๊ธฐ๋ณธ๊ฐ | ์ค๋ช |
---|---|---|---|---|
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 (๋ฐ๋ฆฌ์ด)๋ง๋ค ์บ์๋ฅผ ๊ด๋ฆฌํฉ๋๋ค |
- ์ฃผ์: Bots๋ ์บ์๋ฅผ ์์ฃผ ํ์ฉํฉ๋๋ค. ์ด๋ ๊ณง ๋ฉ๋ชจ๋ฆฌ ์ฌ์ฉ๋์ผ๋ก ์ง๊ฒฐ๋๋ฉฐ autoFlush๋ก ์์ํ๋ ์ต์ ๋ค์ ์ ์ค์ ํด์ฃผ์ธ์.
์ต์ | ํ์ | ํ์ | ๊ธฐ๋ณธ๊ฐ | ์ค๋ช |
---|---|---|---|---|
options.noWarning |
Boolean | false | ๋ชจ๋์ ๊ฒฝ๊ณ ์๋ฆผ์ ๋๋๋ค | |
options.avoidRateLimit |
Boolean | true | ๋ ์ดํธ๋ฆฌ๋ฐ์ ์ต๋ํ ํผํฉ๋๋ค | |
options.autoFlush |
Number | 100 | ์บ์์ ์ ์ฅ๋ ๋ฐ์ดํฐ ์๊ฐ options.autoFlush ๋ฅผ ๋์์ ์บ์๋ฅผ ์ด๊ธฐํํฉ๋๋ค. (์๋ ์บ์ ๊ด๋ฆฌ) |
|
options.autoFlushInterval |
Number | 3600000 | options.autoFlushInterval (๋ฐ๋ฆฌ์ด)๋ง๋ค ์บ์๋ฅผ ๊ด๋ฆฌํฉ๋๋ค |
์ต์ | ํ์ | ํ์ | ๊ธฐ๋ณธ๊ฐ | ์ค๋ช |
---|---|---|---|---|
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))
๐ค zero734kr
- ๊ฐ์ธ Github: @zero734kr
- Organization Github: @koreanbots
์ด์์ PR์ ๋ชจ๋ ํ์์
๋๋ค!
๋ฌด์ธ๊ฐ ๋ฌธ์ ๊ฐ ์๊ฒผ๋ค๋ฉด ์ด์ ํ์ด์ง ๋๋ koreanbots ํตํฉ ์ด์ ํ์ด์ง์ ์ ๋ฅผ ์ธ๊ธํ์ฌ ์๋ ค์ฃผ์ธ์! (์์: @zero734kr, js sdk ๋ฒ๊ทธ์
๋๋ค.)
์ฝ๋ ์์ ์์ฒญ์ PR ํ์ด์ง์ ์ฌ๋ ค์ฃผ์ธ์.
๋ง์ฝ ์ด ๋ชจ๋์ด ๋์์ด ๋์๋ค๋ฉด โญ๏ธ๋ฅผ ๋๋ฌ์ฃผ์ธ์!
Copyright ยฉ 2020 zero734kr.
This project is MIT licensed.
This README was generated with โค๏ธ by readme-md-generator