profile
viewpoint
Antonio Román kyranet @skyra-project Madrid, Spain Videogame Development student at UCM. Fast learner and enthusiast programmer in JS, TS, C#, C++, and Rust.

kyranet/canvas-constructor 69

An ES6 utility for canvas with built-in functions and chained methods.

binarytf/binarytf 15

Binary Term Format

kyranet/canvas-constructor-server 6

A canvas-constructor based API for image generation and microservicing.

kyranet/awesome-klasa 5

A curated list of amazingly awesome Klasa libraries and plugins.

bdistin/discord.js 1

A powerful JavaScript library for interacting with the Discord API

FOG-Yamato/twitterer.js 1

A Twitter API wrapper

kyranet/assemblyscript 1

Definitely not a TypeScript to WebAssembly compiler 🚀

push eventkyranet/obstacle-run

Antonio Román

commit sha d1d577022c37a4b5dda3f7072af85805b300b23f

fix: remove gameobjects and components before itself

view details

push time in 2 hours

push eventkyranet/obstacle-run

Antonio Román

commit sha b7c2fdabd7607b7537a29e5ffeafc989a2d9fc09

feat: first working communication

view details

push time in 4 hours

MemberEvent

push eventkyranet/kyranet

Nejc Drobnic

commit sha 442c6bf894d79856b32979c0d0645c90443013bb

chore: add more source repositories (#1)

view details

push time in 6 hours

push eventkyranet/obstacle-run

Antonio Román

commit sha 0e527e5f1d7e47c7eb218b65f04edb14d149acbd

feat: first semi-operational log in

view details

push time in 6 hours

push eventkyranet/obstacle-run

Antonio Román

commit sha 5e39cbe0a14244fa7cbfbc558584968e0ad99f42

refactor: everything should use transforms

view details

push time in 7 hours

push eventkyranet/obstacle-run

Antonio Román

commit sha e313e1b4d1b30d7633e595e9d99859f0d70d158e

fix: functional server-client communication

view details

push time in 19 hours

push eventkyranet/obstacle-run

Antonio Román

commit sha 9894954d6fe770d197c36aca7d9ea30b8086ef1c

feat: added Component.patch, tidy up all factories

view details

push time in 21 hours

push eventkyranet/obstacle-run

Antonio Román

commit sha 8ff85e08e985b702a7cd2b36d3bb47ac783c4379

feat: use Component::toJson() as a base

view details

push time in a day

push eventkyranet/obstacle-run

Antonio Román

commit sha 132e601bdf0406258c07b6c65a3c7938251fe369

refactor: move toJson to the components

view details

push time in a day

push eventkyranet/obstacle-run

Antonio Román

commit sha 658e70dc7019ef584cd1c67f8703d3b82163bed5

refactor: added string helper methods in Buffer, tweaked smart pointers

view details

push time in a day

push eventkyranet/obstacle-run

Antonio Román

commit sha dafbe314ce58b7a89ae4e724b7cd6227a2f4b62a

fix(server): it's alive!

view details

push time in 2 days

push eventkyranet/obstacle-run

Antonio Román

commit sha dfa780a15cbdf8f36c54b9534195a2d7da776512

feat: added networking into the game

view details

push time in 2 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 54cde6341232ef5015720ed936dd825dfd783ef5

refactor(time): use descriptive variables and inline some logic

view details

push time in 2 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 0de64bac10d8bebad84222d7b51dc2efc409a04b

feat: initial client side code

view details

push time in 2 days

push eventkyranet/kyranet

Antonio Román

commit sha d8e9972f18b1c9dbf6b6b69ef24d4557c7efc745

chore: tweak style and use Quantum's fork for languages

view details

push time in 2 days

push eventkyranet/obstacle-run

Antonio Román

commit sha f72a90a5d805dbd59b7cdc4f72c28f1c55c2a4c1

fix(build): include <thread>

view details

push time in 2 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 5cd7810a2d3ae9f3e8214143e8b02bb4d69917a6

feat: added handle to run server

view details

push time in 2 days

push eventkyranet/obstacle-run

Antonio Román

commit sha b9e0e9d47983f1118cf79f625dd250ff5bfe9562

fix(server): resolved security vulnerability

view details

push time in 2 days

push eventkyranet/obstacle-run

Antonio Román

commit sha b947643fdbbca8e540a59efebe284a33c0b483db

feat: first version of server binary messagery

view details

push time in 2 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 13ffd43e61d315d4d264d6cff93d31aa9b6ca80f

feat: initial server setup

view details

push time in 3 days

Pull request review commentdiscordjs/discord.js

feat: bypass cache check with forceFetch param

 class MessageManager extends BaseManager {    *   .then(messages => console.log(`${messages.filter(m => m.author.id === '84484653687267328').size} messages`))    *   .catch(console.error);    */-  fetch(message, cache = true) {-    return typeof message === 'string' ? this._fetchId(message, cache) : this._fetchMany(message, cache);+  fetch(message, cache = true, force = true) {

This default (true) does not match the default in the JSDocs (line 48, documented as false).

Fyko

comment created time in 3 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 7d0ab02222618e467ad0e10848344f1c600d5e6d

feat(player): add bullet cooldown

view details

push time in 3 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 2771a0f61fff205747ea82ed265f602b4299cfe9

feat: added wall spawn

view details

push time in 3 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 747d57c12f4039bc5b54d9eb378f188b7779e9e1

feat(player): limit bullets

view details

push time in 3 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 6dc39ef96e49c4479bef44733922535015df9265

feat(physics): make density and restitution configurable

view details

push time in 3 days

startedmicrosoft/fast

started time in 3 days

push eventkyranet/obstacle-run

Antonio Román

commit sha a21706ef3f9cf085574f0be76347bbca63273897

feat: functional bullet boxes

view details

push time in 3 days

IssuesEvent

Pull request review commentdiscordjs/discord.js

feat(Guild): discovery splash

 class Guild extends Base {     return this.edit({ splash: await DataResolver.resolveImage(splash), reason });   } +  /**+   * Sets a new guild discovery splash image.+   * @param {Base64Resolvable|BufferResolvable} discoverySplash The new discovery splash image of the guild+   * @param {string} [reason] Reason for changing the guild's discovery splash image+   * @returns {Promise<Guild>}+   * @example+   * // Edit the guild discovery splash+   * guild.setDiscoverySplash('./discoverysplash.png')+   *  .then(updated => console.log('Updated the guild discovery splash'))+   *  .catch(console.error);

We are using two spaces of indentation for examples, however, there is only one space here:

   *   .then(updated => console.log('Updated the guild discovery splash'))
   *   .catch(console.error);
advaith1

comment created time in 3 days

Pull request review commentdiscordjs/discord.js

docs(Constants): Improve large_threshold description

 exports.DefaultOptions = {   /**    * WebSocket options (these are left as snake_case to match the API)    * @typedef {Object} WebsocketOptions-   * @property {number} [large_threshold=250] Number of members in a guild to be considered large+   * @property {number} [large_threshold=250] Number of members in a guild where offline users will no longer be sent

I'm pretty sure number is correct in this instance

number is used for things that can be counted, while amount is used for things that cannot be counted

You are right, per https://www.enago.com/academy/understanding-the-difference-between-number-and-amount/

The answer lies in the English distinction between count and non-count nouns. Although number and amount have similar meanings, number is used for things that can be counted, while amount is used for things that cannot be counted.

I edited the comment to delete the suggestion and let it fallback to the previous, which uses "number".

advaith1

comment created time in 3 days

Pull request review commentdiscordjs/discord.js

fix(Integration): user might not be present

 declare module 'discord.js' {     public syncedAt: number;     public syncing: boolean;     public type: string;-    public user: User;+    public user: User | null;

The property isn't set when data.user is missing, however, you can either make the field as optional (see suggestion below), or default it to null.

    public user?: User;
advaith1

comment created time in 3 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 4239d29fc5544b75c1b2aa1af8e69e8d15bad848

feat: first step at bullet boxes

view details

push time in 4 days

Pull request review commentdiscordjs/discord.js

docs(Constants): Improve large_threshold description

 exports.DefaultOptions = {   /**    * WebSocket options (these are left as snake_case to match the API)    * @typedef {Object} WebsocketOptions-   * @property {number} [large_threshold=250] Number of members in a guild to be considered large+   * @property {number} [large_threshold=250] Number of members in a guild where offline users will no longer be sent

You're right, amount sounds better than number here.

   * @property {number} [large_threshold=250] Amount of members in a guild after which offline users will no longer be sent in the initial guild member list, must be between 50 and 250
advaith1

comment created time in 4 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 634737cb9050f2883ee404c79bc4e494eeaf240d

feat: added collectibles and contact listener

view details

push time in 4 days

Pull request review commentdiscordjs/discord.js

docs(Client): fix docs for login method

 class Client extends BaseClient {     Object.defineProperty(this, 'token', { writable: true });     if (!browser && !this.token && 'DISCORD_TOKEN' in process.env) {       /**-       * Authorization token for the logged in bot+       * Authorization token for the logged in bot.+       * Gets set to `process.env.DISCORD_TOKEN` when instantiating the client

I like this alternative 👍

Vaporox

comment created time in 4 days

Pull request review commentdiscordjs/discord.js

docs(Constants): Improve large_threshold description

 exports.DefaultOptions = {   /**    * WebSocket options (these are left as snake_case to match the API)    * @typedef {Object} WebsocketOptions-   * @property {number} [large_threshold=250] Number of members in a guild to be considered large+   * @property {number} [large_threshold=250] Number of members in a guild where offline users will no longer be sent

Ah, what about this? Picking bits from @vladfrangu's and Discord's suggestion:

   * @property {number} [large_threshold=250] Number of members in a guild after which offline users will no longer be sent in the initial guild member list, must be between 50 and 250

"Number of total members" sounds weird to me.

advaith1

comment created time in 4 days

Pull request review commentdiscordjs/discord.js

docs(Client): fix docs for login method

 class Client extends BaseClient {     Object.defineProperty(this, 'token', { writable: true });     if (!browser && !this.token && 'DISCORD_TOKEN' in process.env) {       /**-       * Authorization token for the logged in bot+       * Authorization token for the logged in bot.+       * Gets set to `process.env.DISCORD_TOKEN` when instantiating the client

Alternative wording:

       * Defaults to `process.env.DISCORD_TOKEN` when instantiating the client if it was defined
Vaporox

comment created time in 4 days

Pull request review commentdiscordjs/discord.js

feat(GuildMemberManager): add 'search' method

 class GuildMemberManager extends BaseManager {     return this._fetchMany(options);   } +  /**+   * Search for members in the guild based on a query+   * @param {Object} options Search options+   * @property {string} options.query Members whose usernames or nicknames that start with

Alternatively, what about this?

   * @property {string} options.query Filter members whose username or nickname start with the query.
izexi

comment created time in 4 days

Pull request review commentdiscordjs/discord.js

Clarify vanity URL documentation

 class Guild extends Base {     }      /**-     * The vanity URL code of the guild, if any+     * The vanity URL code of the guild, if any. This only includes the invite code; not the entire URL

Proposing different wording:

     * The vanity invite code of the guild, if any

You don't need to specify that it's not the entire URL if you don't mention URL in the first place.

Technoguyfication

comment created time in 4 days

Pull request review commentdiscordjs/discord.js

docs(Constants): Improve large_threshold description

 exports.DefaultOptions = {   /**    * WebSocket options (these are left as snake_case to match the API)    * @typedef {Object} WebsocketOptions-   * @property {number} [large_threshold=250] Number of members in a guild to be considered large+   * @property {number} [large_threshold=250] Number of members in a guild where offline users will no longer be sent

To propose a different wording: Number of online users in a guild after which offline ones will no longer be sent in the initial guild member list, between 50 and 250.

I first thought of "Number of non-offline" but the opposite of that is online, and it was duplicating the word "offline". Thoughts?

advaith1

comment created time in 4 days

push eventkyranet/obstacle-run

Antonio Román

commit sha dfe34949deafb9a62add44ba22d804a3fcbf97e2

feat: sensor physics objects and masks

view details

push time in 4 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 07aca67a7fe799f1641b2d005dc234548aed588d

feat: added collision detection

view details

push time in 4 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 47dee9c0360f3e880a7913aa3625bfeb4259efc2

fix: resolved build on linux

view details

push time in 4 days

Pull request review commentskyra-project/skyra

refactor: commit linting

 {-	"extends": "@skyra",+	"extends": ["@skyra", "plugin:prettier/recommended"],

Skyra's eslint config uses TS's rules, adding prettier/@typescript-eslint before this one will disable the style keys, then plugin:prettier/recommended would set them without conflicts.

QuantumlyTangled

comment created time in 5 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 676814cef032e625e2b5476b7e8401cdfb2e0d7b

legal: include NovelRT's license to the project Thank you Matt Jones and Contributors for such amazing CMake recipes ❤

view details

push time in 5 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 0276ba0093a37f25804390291913105916e3f943

refactor: switch to box2d for physics

view details

push time in 5 days

push eventkyranet/obstacle-run

Antonio Román

commit sha fe2a861353b12ddb28a39fd9870dd4d6580eadc9

feat(physics): first step

view details

push time in 5 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 0117ccb95ac1053f408c2149c593e1c1ce1c84bb

refactor: more smart pointers!

view details

push time in 5 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 21abd5dedef741a456b779e563b223663ef54a95

refactor(vector-x): better templates and code

view details

push time in 5 days

push eventkyranet/obstacle-run

Antonio Román

commit sha d423c0995c07776ab1ff9ebd3954371757d30e99

refactor(cmanager): use smart pointers and add thread safety

view details

push time in 6 days

push eventkyranet/obstacle-run

Antonio Román

commit sha ebf92ab31a2ef7cda9fcf0f2a87a4027f4389233

refactor(component-manager): refactor to smart pointers

view details

push time in 6 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 9014ec2ece74380507e9eed396396b6369f3910a

fix(build): resolved gcc error

view details

push time in 6 days

push eventkyranet/obstacle-run

Antonio Román

commit sha faf6f545a376384135986fab02fb75e175c2aafe

refactor: use smart pointers a little better

view details

push time in 6 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 4378255f5f4e14c81ca6ecb0e75a8d355995cee3

refactor: use smart pointers in most places

view details

push time in 6 days

push eventkyranet/obstacle-run

Antonio Román

commit sha e868fece7e77677bfbab0563b4fb0202c61d4c2b

fix(build): resolved errors on gcc

view details

push time in 6 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 999db899f23e6dec7d64b0d4d48cb1bb17f29b95

feat(gameobject): add GO->scene()

view details

push time in 6 days

push eventkyranet/obstacle-run

Antonio Román

commit sha aaf9ab44bda6a71d851923021666ea08ec192a5b

refactor(vector-x): remove 'from' methods

view details

push time in 6 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 1b46340919e2e9bb1b6d0dcf7392a80ad4900b4f

feat(core): add Time utility for delta time

view details

push time in 6 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 5f15dd0d7e986879e59cebd6513df0da2b1035d6

feat(components): add PlayerController

view details

push time in 6 days

push eventkyranet/obstacle-run

Antonio Román

commit sha f1d04d9e42ff518af40414b8ab6df5756eb73162

fix(solid-renderer): resolve runtime errors

view details

push time in 6 days

delete branch kyranet/canvas-constructor

delete branch : depfu/batch_all/yarn/2020-08-09

delete time in 6 days

push eventkyranet/canvas-constructor

depfu[bot]

commit sha 86e933afeaedaa7bbce50f81fda367354bb8c005

Update all Yarn dependencies (2020-08-09) (#358) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com>

view details

push time in 6 days

PR merged kyranet/canvas-constructor

Update all Yarn dependencies (2020-08-09)

This is your weekly update of all Yarn dependencies. Please take a good look at what changed and the test results before merging this pull request.

What changed?

✳️ @typescript-eslint/eslint-plugin (3.7.1 → 3.8.0, minor) · Repo · Changelog · Release · Diff

✳️ @typescript-eslint/parser (3.7.1 → 3.8.0, minor) · Repo · Changelog · Release · Diff

✳️ rollup-plugin-typescript2 (0.27.1 → 0.27.2, minor) · Repo · Release · Diff

✳️ rollup (2.23.0 → 2.23.1, patch) · Repo · Changelog · Release · Diff


Depfu Status

Depfu will only send you the next scheduled PR once you merge or close this one.

<details><summary>All Depfu comment commands</summary> <blockquote><dl> <dt>@​depfu refresh</dt><dd>Rebases against your default branch and redoes this update</dd> <dt>@​depfu recreate</dt><dd>Recreates this PR, overwriting any edits that you've made to it</dd> <dt>@​depfu merge</dt><dd>Merges this PR once your tests are passing and conflicts are resolved</dd> <dt>@​depfu close</dt><dd>Closes this PR and deletes the branch</dd> <dt>@​depfu reopen</dt><dd>Restores the branch and reopens this PR (if it's closed)</dd> </dl></blockquote> </details>

+53 -60

0 comment

2 changed files

depfu[bot]

pr closed time in 6 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 7fbca78967e12dd36b4635878a8d1a4e839d2105

feat: added solid renderer

view details

push time in 7 days

startedskyra-project/timestamp

started time in 7 days

push eventskyra-project/timestamp

Antonio Román

commit sha 4c2379551606207191a55135fa4767d9fa0766ba

feat: added test and coverage workflows

view details

push time in 7 days

release skyra-project/timestamp

v1.0.0

released time in 7 days

push eventskyra-project/timestamp

Antonio Román

commit sha 2a697a7f4b6770ab0561178ff95bca0cdfb99ea7

v1.0.0

view details

push time in 7 days

created tagskyra-project/timestamp

tagv1.0.0

A timestamp generation tool used in klasa.

created time in 7 days

delete branch skyra-project/timestamp

delete branch : docs

delete time in 7 days

create barnchskyra-project/timestamp

branch : gh-pages

created branch time in 7 days

push eventkyranet/obstacle-run

Antonio Román

commit sha e28fea00ad388342b9710291c09e33cc990d0d11

refactor: use chrono instead of TimePool

view details

Antonio Román

commit sha b5689c14c65acac8b4c307e6ec32876f8defd6d5

refactor(input): change from singleton to static class

view details

push time in 7 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 07231dad21ce95203d23026731e92e98b17b8979

refactor: bring more consistency

view details

push time in 7 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 26ba1076a3870bc0cfab926e4b2dc5102bc5bc28

feat: add interactive buttons

view details

push time in 8 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 0a5097c2c411094658ac91a7c80493f1fb31a30c

refactor: separate update and render pipelines

view details

push time in 8 days

push eventkyranet/obstacle-run

Antonio Román

commit sha c471d9b9b137798e55f44fbcb09ab38e96b8ff10

feat: added image strategies

view details

push time in 8 days

startedpostwoman-io/postwoman

started time in 8 days

push eventskyra-project/skyra

Soumil07

commit sha 95436bb22aa7c3bb1dda6dd92a2cf16a6f6c8a45

feat: trivia command (#1181) Co-authored-by: Antonio Román <kyradiscord@gmail.com>

view details

push time in 8 days

PR merged skyra-project/skyra

feat: trivia command
+295 -1

0 comment

9 changed files

Soumil07

pr closed time in 8 days

Pull request review commentskyra-project/skyra

patch(createMute): react to original message

 export default class extends SkyraCommand { 			description: language => language.tget('COMMAND_CREATEMUTE_DESCRIPTION'), 			extendedHelp: language => language.tget('COMMAND_CREATEMUTE_EXTENDED'), 			permissionLevel: PermissionLevels.Administrator,-			requiredGuildPermissions: ['MANAGE_CHANNELS', 'MANAGE_ROLES'],+			requiredGuildPermissions: ['MANAGE_CHANNELS', 'MANAGE_ROLES', 'USE_EXTERNAL_EMOJIS', 'ADD_REACTIONS', 'READ_MESSAGE_HISTORY'],

Those permissions are guild-wide, Skyra might have them revoked specifically in the channel, or granted.

What I meant was to add if (message.reactable) await message.react(...);, maybe with a text branch as fallback.

Soumil07

comment created time in 8 days

Pull request review commentskyra-project/saelem

feat: add caching [skip publish]

 const kConsole = new KlasaConsole({ const port = process.env.PORT || 8284; const server = gqlServer(); +// Sweep the cache daily+setInterval(sweepOldCache, constants.DAY);

Bold of you to assume this will run in exactly one day.

Favna

comment created time in 9 days

Pull request review commentskyra-project/skyra

patch(createMute): react to original message

 export default class extends SkyraCommand { 			await message.guild!.settings.update(GuildSettings.Roles.Muted, role, { 				extraContext: { author: message.author.id } 			});+			await message.react(resolveEmoji(Emojis.GreenTick)!);

The permissions are not checked, you're taking for granted that Skyra will have all ADD_REACTIONS, USE_EXTERNAL_EMOJIS, and READ_CHANNEL_HISTORY permissions, while it's rare for her to lack any of those, it can happen.

Soumil07

comment created time in 9 days

Pull request review commentskyra-project/skyra

feat: trivia command

+/* eslint-disable @typescript-eslint/no-use-before-define */+import { fetch, FetchResultTypes } from '@utils/util';++/**+ * This class will also be used for handling complete games of Trivia+ */+// eslint-disable-next-line @typescript-eslint/no-extraneous-class+export default class TriviaManager {++	public static async getQuestion(category: number, difficulty = QuestionDifficulty.EASY, questionType = QuestionType.MULTIPLE) {+		const url = new URL('https://opentdb.com/api.php');+		url.searchParams.append('amount', '1');+		url.searchParams.append('category', category.toString());+		url.searchParams.append('difficulty', difficulty);+		url.searchParams.append('type', questionType);++		const { response_code, results } = await fetch<TriviaResultOk>(url, FetchResultTypes.JSON);+		if (response_code === 0 && results.length) return results[0];+		throw new Error('Invalid request');+	}++}++export interface TriviaResultOk {+	response_code: number;+	results: QuestionData[];+}++/**+ * The question object returned by OpenTDB+ */+export interface QuestionData {+	category: string;+	type: QuestionType;+	difficulty: QuestionDifficulty;+	question: string;+	correct_answer: string;+	incorrect_answers: string[];+}++export const enum QuestionType {+	BOOLEAN = 'boolean',+	MULTIPLE = 'multiple'+}++export const enum QuestionDifficulty {+	EASY = 'easy',+	MEDIUM = 'medium',+	HARD = 'hard'+}

Our convention on enum member names are the same as C#'s: PascalCase.

Soumil07

comment created time in 9 days

Pull request review commentskyra-project/skyra

feat: trivia command

+import { SkyraCommand, SkyraCommandOptions } from '@lib/structures/SkyraCommand';+import { ApplyOptions } from '@skyra/decorators';+import { KlasaMessage, KlasaUser } from 'klasa';+import TriviaManager, { CATEGORIES, QuestionType, QuestionDifficulty, QuestionData } from '@utils/Games/TriviaManager';+import { decode } from 'he';+import { shuffle } from '@utils/util';+import { MessageEmbed, MessageCollector } from 'discord.js';++@ApplyOptions<SkyraCommandOptions>({+	cooldown: 5,+	description: language => language.tget('COMMAND_TRIVIA_DESCRIPTION'),+	extendedHelp: language => language.tget('COMMAND_TRIVIA_EXTENDED'),+	usage: '(category:category) [boolean|multiple] [easy|hard|medium] [duration:int{30,60}]',+	usageDelim: ' '+})+export default class extends SkyraCommand {++	// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility+	#channels = new Set<string>();++	public async run(message: KlasaMessage, [category, questionType = undefined, difficulty = undefined, duration = 30]: [number, QuestionType?, QuestionDifficulty?, number?]) {+		if (this.#channels.has(message.channel.id)) throw message.language.tget('COMMAND_TRIVIA_ACTIVE_GAME');++		this.#channels.add(message.channel.id);+		await message.sendLocale('SYSTEM_LOADING');+		const data = await TriviaManager.getQuestion(category, difficulty, questionType);+		const possibleAnswers = questionType === QuestionType.BOOLEAN+			? ['True', 'False']+			: shuffle([data.correct_answer, ...data.incorrect_answers].map(ans => decode(ans)));+		const correctAnswer = decode(data.correct_answer);++		await message.sendEmbed(this.buildQuestionEmbed(message, data, possibleAnswers));+		const filter = (msg: KlasaMessage) => {+			const num = parseInt(msg.content, 10);

We always use Number, since parseInt('11aa'); returns 11 instead of NaN.

Soumil07

comment created time in 9 days

Pull request review commentskyra-project/skyra

feat: trivia command

+import { SkyraCommand, SkyraCommandOptions } from '@lib/structures/SkyraCommand';+import { ApplyOptions } from '@skyra/decorators';+import { KlasaMessage, KlasaUser } from 'klasa';+import TriviaManager, { CATEGORIES, QuestionType, QuestionDifficulty, QuestionData } from '@utils/Games/TriviaManager';+import { decode } from 'he';+import { shuffle } from '@utils/util';+import { MessageEmbed, MessageCollector } from 'discord.js';++@ApplyOptions<SkyraCommandOptions>({+	cooldown: 5,+	description: language => language.tget('COMMAND_TRIVIA_DESCRIPTION'),+	extendedHelp: language => language.tget('COMMAND_TRIVIA_EXTENDED'),+	usage: '(category:category) [boolean|multiple] [easy|hard|medium] [duration:int{30,60}]',+	usageDelim: ' '+})+export default class extends SkyraCommand {++	// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility+	#channels = new Set<string>();++	public async run(message: KlasaMessage, [category, questionType = undefined, difficulty = undefined, duration = 30]: [number, QuestionType?, QuestionDifficulty?, number?]) {+		if (this.#channels.has(message.channel.id)) throw message.language.tget('COMMAND_TRIVIA_ACTIVE_GAME');++		this.#channels.add(message.channel.id);+		await message.sendLocale('SYSTEM_LOADING');+		const data = await TriviaManager.getQuestion(category, difficulty, questionType);+		const possibleAnswers = questionType === QuestionType.BOOLEAN+			? ['True', 'False']+			: shuffle([data.correct_answer, ...data.incorrect_answers].map(ans => decode(ans)));+		const correctAnswer = decode(data.correct_answer);++		await message.sendEmbed(this.buildQuestionEmbed(message, data, possibleAnswers));+		const filter = (msg: KlasaMessage) => {+			const num = parseInt(msg.content, 10);+			return Number.isInteger(num) && num > 0 && num <= possibleAnswers.length;+		};+		const collector = new MessageCollector(message.channel, filter, { time: duration * 1000 });++		let winner: KlasaUser | null = null;+		// users who have already participated+		const participants = new Set<string>();++		collector.on('collect', (collected: KlasaMessage) => {+			if (participants.has(collected.author.id)) return;+			const attempt = possibleAnswers[parseInt(collected.content, 10) - 1];+			if (attempt === decode(data.correct_answer)) {+				winner = collected.author;+				return collector.stop();+			}+			participants.add(collected.author.id);+			return message.channel.sendLocale('COMMAND_TRIVIA_INCORRECT', [attempt]);+		});++		collector.on('end', () => {+			this.#channels.delete(message.channel.id);+			if (!winner) return message.channel.sendLocale('COMMAND_TRIVIA_NO_ANSWER', [correctAnswer]);+			return message.channel.sendLocale('COMMAND_TRIVIA_WINNER', [winner, correctAnswer]);+		});++	}++	public buildQuestionEmbed(message: KlasaMessage, data: QuestionData, possibleAnswers: string[]) {+		const TITLES = message.language.tget('COMMAND_TRIVIA_EMBED_TITLES');+		const questionDisplay = possibleAnswers.map((possible, i) => `${i + 1}. ${possible}`);+		return new MessageEmbed()+			.setAuthor(TITLES.TRIVIA)+			.setTitle(data.category)+			.setColor(0xf37917)+			.setThumbnail('http://i.imgur.com/zPtu5aP.png')+			.setDescription([+				`${TITLES.DIFFICULTY}: ${data.difficulty}`,+				'',+				decode(data.question),+				'',+				questionDisplay.join('\n')+			].join('\n'));+	}++	public async init() {+		this.createCustomResolver('category', (arg, possible, message) => {+			if (!arg) return CATEGORIES.general;+			arg = arg.toLowerCase();+			if (!Reflect.has(CATEGORIES, arg)) throw message.language.tget('COMMAND_TRIVIA_INVALID_CATEGORY');+			return Reflect.get(CATEGORIES, arg);

has + get is an anti-pattern, get once and check its value.

Soumil07

comment created time in 9 days

Pull request review commentskyra-project/skyra

feat: trivia command

+/* eslint-disable @typescript-eslint/no-use-before-define */+import { fetch, FetchResultTypes } from '@utils/util';++/**+ * This class will also be used for handling complete games of Trivia+ */+// eslint-disable-next-line @typescript-eslint/no-extraneous-class

This rule is enforced in Skyra and should not be disabled. Static classes are similar to namespaces, and as such, just using export async function getQuestion(...) { ... } is prefered.

Soumil07

comment created time in 9 days

Pull request review commentskyra-project/skyra

feat: trivia command

+import { SkyraCommand, SkyraCommandOptions } from '@lib/structures/SkyraCommand';+import { ApplyOptions } from '@skyra/decorators';+import { KlasaMessage, KlasaUser } from 'klasa';+import TriviaManager, { CATEGORIES, QuestionType, QuestionDifficulty, QuestionData } from '@utils/Games/TriviaManager';+import { decode } from 'he';+import { shuffle } from '@utils/util';+import { MessageEmbed, MessageCollector } from 'discord.js';++@ApplyOptions<SkyraCommandOptions>({+	cooldown: 5,+	description: language => language.tget('COMMAND_TRIVIA_DESCRIPTION'),+	extendedHelp: language => language.tget('COMMAND_TRIVIA_EXTENDED'),+	usage: '(category:category) [boolean|multiple] [easy|hard|medium] [duration:int{30,60}]',+	usageDelim: ' '+})+export default class extends SkyraCommand {++	// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility+	#channels = new Set<string>();++	public async run(message: KlasaMessage, [category, questionType = undefined, difficulty = undefined, duration = 30]: [number, QuestionType?, QuestionDifficulty?, number?]) {+		if (this.#channels.has(message.channel.id)) throw message.language.tget('COMMAND_TRIVIA_ACTIVE_GAME');++		this.#channels.add(message.channel.id);+		await message.sendLocale('SYSTEM_LOADING');+		const data = await TriviaManager.getQuestion(category, difficulty, questionType);+		const possibleAnswers = questionType === QuestionType.BOOLEAN+			? ['True', 'False']

Move to i18n, as well as make them lower-case so we can match them with .toLowerCase().

Soumil07

comment created time in 9 days

Pull request review commentskyra-project/skyra

feat: trivia command

+import { SkyraCommand, SkyraCommandOptions } from '@lib/structures/SkyraCommand';+import { ApplyOptions } from '@skyra/decorators';+import { KlasaMessage, KlasaUser } from 'klasa';+import TriviaManager, { CATEGORIES, QuestionType, QuestionDifficulty, QuestionData } from '@utils/Games/TriviaManager';+import { decode } from 'he';+import { shuffle } from '@utils/util';+import { MessageEmbed, MessageCollector } from 'discord.js';++@ApplyOptions<SkyraCommandOptions>({+	cooldown: 5,+	description: language => language.tget('COMMAND_TRIVIA_DESCRIPTION'),+	extendedHelp: language => language.tget('COMMAND_TRIVIA_EXTENDED'),+	usage: '(category:category) [boolean|multiple] [easy|hard|medium] [duration:int{30,60}]',+	usageDelim: ' '+})+export default class extends SkyraCommand {++	// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility+	#channels = new Set<string>();++	public async run(message: KlasaMessage, [category, questionType = undefined, difficulty = undefined, duration = 30]: [number, QuestionType?, QuestionDifficulty?, number?]) {+		if (this.#channels.has(message.channel.id)) throw message.language.tget('COMMAND_TRIVIA_ACTIVE_GAME');++		this.#channels.add(message.channel.id);

Please dispose this data with a try/finally. Lines 25, 26, and 32 can throw errors.

Soumil07

comment created time in 9 days

Pull request review commentskyra-project/skyra

feat: country command

+import { SkyraCommand, SkyraCommandOptions } from '@lib/structures/SkyraCommand';+import { ApplyOptions } from '@skyra/decorators';+import { fetch } from '@utils/util';+import { KlasaMessage } from 'klasa';+import { MessageEmbed } from 'discord.js';+import { BrandingColors } from '@utils/constants';+import { UserRichDisplay } from '@lib/structures/UserRichDisplay';+import { DbSet } from '@lib/structures/DbSet';++const mapNativeName = (data: { name: string; nativeName: string }) => `${data.name} ${data.nativeName === data.name ? '' : `(${data.nativeName})`}`;+const mapCurrency = (currency: CurrencyData) => `${currency.name} (${currency.symbol})`;++@ApplyOptions<SkyraCommandOptions>({+	description: language => language.tget('COMMAND_COUNTRY_DESCRIPTION'),+	extendedHelp: language => language.tget('COMMAND_COUNTRY_EXTENDED'),+	usage: '<country:str>'+})+export default class extends SkyraCommand {++	public async run(message: KlasaMessage, [countryName]: [string]) {+		const response = await message.sendEmbed(new MessageEmbed()+			.setDescription(message.language.tget('SYSTEM_LOADING'))+			.setColor(BrandingColors.Secondary));++		const countries = await this.fetchAPI(message, countryName);+		if (countries.length === 0) throw message.language.tget('SYSTEM_QUERY_FAIL');++		const display = await this.buildDisplay(message, countries);+		await display.start(response, message.author.id);+		return response;+	}++	private async fetchAPI(message: KlasaMessage, countryName: string) {+		const apiResult = await fetch<CountryApiResult>(`https://restcountries.eu/rest/v2/name/${encodeURIComponent(countryName)}`)+			.catch(() => { throw message.language.tget('SYSTEM_QUERY_FAIL'); });+		if (Reflect.has(apiResult, 'status') && (apiResult as CountryResultError).status === 404) {+			throw message.language.tget('SYSTEM_QUERY_FAIL');+		}

Does the API return 200 OK on a 404? utils.fetch throws on 400-599 status codes.

Soumil07

comment created time in 9 days

push eventkyranet/obstacle-run

Antonio Román

commit sha e42ef303196487281a38e13116693ea36a3e76b7

feat(image-renderer): first step at images

view details

push time in 9 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 168b96859540618c5b708684567738c782cefb5e

fix(debug-print): resolved g++ vulnerability report

view details

push time in 9 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 377ba53271bede0c71728eeafdcc0d26d51b8a4e

fix(debug-print): resolved g++ vulnerability report

view details

push time in 9 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 3e87d3da9c49eb7f7eed2ed23cd70381c02f038a

feat(text-renderer): added more options

view details

push time in 9 days

push eventkyranet/obstacle-run

Antonio Román

commit sha ac337a1a1645594db05440b1428da98e3366f61b

feat: fonts now render!

view details

push time in 9 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 2853d39b90155aacf16a4d7dfad17265f0d751af

feat: added font loading

view details

push time in 9 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 2a1deca8114b989ffe8412020639fb84266bea99

refactor: use built-in assert instead of custom assert

view details

push time in 9 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 4519c7241596ac1285243a6c9b945ac05c2b07eb

refactor: use better setter/getter pattern

view details

push time in 9 days

push eventkyranet/obstacle-run

Antonio Román

commit sha 0313448e26e96fd3177beb2e5df84e8745d798af

feat(component,gameobject): add methods to find components

view details

push time in 10 days

more