buape / amaribot.js Goto Github PK
View Code? Open in Web Editor NEWThe Javascript library for the AmariBot API
Home Page: https://amaribot.js.org
License: MIT License
The Javascript library for the AmariBot API
Home Page: https://amaribot.js.org
License: MIT License
This system will automatically queue requests that you make when you are ratelimited
Describe the bug
In Typescript, developers are forced to provide both token: string
and options: AmariBotOptions
. options
requires a token
to be passed even though it was already passed. I believe that's because of this line:
https://github.com/amaribot/amaribot.js/blob/46070dbf47db07f13c3d31d9268665b3c2d1ef6e/src/index.d.ts#L10
where, unlike in the actual Javascript code, options
is not being defaulted to {}
.https://github.com/amaribot/amaribot.js/blob/46070dbf47db07f13c3d31d9268665b3c2d1ef6e/src/AmariBot.js#L17
To Reproduce
Steps to reproduce the behavior:
4.9.5
import the package like so import amariBotImporter from "amaribot.js"
AmariBot
viaconst importer = new amariBotImporter.AmariBot(process.env.AMARIBOT_API_KEY as string)
Expected 2 arguments, but got 1. ts(2554)
index.d.ts(10, 43): An argument for 'options' was not provided.
Expected behavior
The developer only needs to provide the token once.
Versions
19.6.0
7.27.0
1.6.1
4.9.5
Additional context
In addition to this being fixed, https://github.com/amaribot/amaribot.js/blob/46070dbf47db07f13c3d31d9268665b3c2d1ef6e/src/index.d.ts#L79 should be optional/not exist since the developer already provided the token in the first token: string
argument.
Describe the bug
Throws error when baseURL
option ends with a slash (/).
if (options.baseURL !== undefined && options.baseURL.endsWith("/")) throw new Error("baseURL must end with a /")
I'm assuming should be changed to
if (options.baseURL !== undefined && !options.baseURL.endsWith("/")) throw new Error("baseURL must end with a /")
To Reproduce
Steps to reproduce the behavior:
new AmariBot("AMARIBOTAPITOKEN", { baseURL: "https://amaribot.com/api/" })
Expected behavior
No error.
Versions
Additional context
Unrelated to this but the leaderboard and rewards examples don't work.
Its reassigning the AmariBot constant in both examples:
SyntaxError: Identifier 'AmariBot' has already been declared
and the in the rewards example something similar is happening:
SyntaxError: Identifier 'level' has already been declared
.
Also in the rewards example message
is not declared, but I don't
know if that example is meant to be in a message event.
Make it so when calling the function guildID and userID don't have to be Strings
I've made a proxy with CloudFlare workers to hide my exact IP address. I want to be able to use it with amaribot.js, but amaribot.js only uses the regular fetch API, which doesn't go through the proxy.
I would like to be able to replace the fetch module within amaribot.js as a config option upon initiating the client with one of my own methods or functions, such as this one:
/**
* @param {String} endpoint
* @param {RequestInit} options
* @returns {Promise<Response>}
*/
async function fetch(endpoint, options={}) {
return new Promise(async (resolve) => {
const res = await fetch("https://uri.to.my.request.proxy.worker.oirnoir.workers.dev/", {...options, headers: {endpoint, headers: options.headers == null ? "{}" : JSON.stringify(options.headers)}, cache: "no-cache"});
const receivedHeaders = res.headers.has("incomingHeaders") ? JSON.parse(res.headers.get("incomingHeaders")) : null;
res.proxyHeaders = res.headers;
if (receivedHeaders != null) {
Object.defineProperty(res, "headers", {get: () => new Headers(receivedHeaders)});
}
return resolve(res);
});
}
The function has the exact same syntax as the built-in fetch API, but requests through my cloudflare workers proxy. It returns the data in the exact same format. I want to be able to replace the fetch api within amaribot.js with my own function (it can do anything, it just needs to accept and return similar values as the fetch api would). The function above is just an example input.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.