mirror of
https://gitdab.com/cadence/out-of-your-element.git
synced 2025-09-10 04:12:50 +02:00
Add snowflake timestamp converter functions
This commit is contained in:
parent
8026cf0cad
commit
8439512f1a
4 changed files with 39 additions and 27 deletions
23
discord/utils.test.js
Normal file
23
discord/utils.test.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
const {test} = require("supertape")
|
||||
const data = require("../test/data")
|
||||
const utils = require("./utils")
|
||||
|
||||
test("is webhook message: identifies bot interaction response as not a message", t => {
|
||||
t.equal(utils.isWebhookMessage(data.interaction_message.thinking_interaction), false)
|
||||
})
|
||||
|
||||
test("is webhook message: identifies webhook interaction response as not a message", t => {
|
||||
t.equal(utils.isWebhookMessage(data.interaction_message.thinking_interaction_without_bot_user), false)
|
||||
})
|
||||
|
||||
test("is webhook message: identifies webhook message as a message", t => {
|
||||
t.equal(utils.isWebhookMessage(data.special_message.bridge_echo_webhook), true)
|
||||
})
|
||||
|
||||
test("discord utils: converts snowflake to timestamp", t => {
|
||||
t.equal(utils.snowflakeToTimestampExact("86913608335773696"), 1440792219004)
|
||||
})
|
||||
|
||||
test("discerd utils: converts timestamp to snowflake", t => {
|
||||
t.match(utils.timestampToSnowflakeInexact(1440792219004), /^869136083357.....$/)
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue