Code Monkey home page Code Monkey logo

discordeno's Introduction

Discordeno

Discord API library for Node.JS, Deno & Bun

Discord codecov action status

Tips

  • If you are already convinced about using Discordeno, go to Getting Started
  • To learn if Discordeno is right for you, read everything below.

Packages

Package npm Tests
discordeno npm (scoped) codecov
@discordeno/types npm (scoped) codecov
@discordeno/utils npm (scoped) codecov
@discordeno/rest npm (scoped) codecov
@discordeno/gateway npm (scoped) codecov
@discordeno/bot npm (scoped) codecov

Features

Discordeno is actively maintained to guarantee excellent performance, latest features, and ease of use.

  • Simple, Efficient, and Lightweight: Discordeno is lightweight, simple to use, and adaptable.
    • By default: No caching.
  • Functional API:
    • The functional API eliminates the challenges of extending built-in classes and inheritance while ensuring overall simple but performant code.
  • Cross Runtime: Supports the Node.js, Deno, and Bun runtimes.
  • Standalone components: Discordeno offers the option to have practically any component of a bot as a separate piece, including standalone REST, gateways, custom caches, and more.
  • Flexibility/Scalability: Remove any properties, if your bot doesn't need them. For instance, remove Channel.topic if your bot doesn't require it. You may save GBs of RAM in this way. A few lines of code are all that are needed to accomplish this for any property on any object.

REST

  • Freedom from 1 hour downtimes due to invalid requests
    • Prevent your bot from being down for an hour, by lowering the maximum downtime to 10 minutes.
  • Freedom from global rate limit errors
    • As a bot grows, you need to handle global rate limits better. Shards don't communicate fast enough to truly handle it properly. With one point of contact to discords API, you will never have issues again.
    • Numerous instances of your bot on different hosts, all of which can connect to the same REST server.
  • REST does not rest!
    • Separate rest guarantees that your queued requests will continue to be processed even if your bot breaks for whatever reason.
    • Seamless updates! When updating/restarting a bot, you'll lose a lot of messages or replies that are queued/processing.
  • Single point of contact to Discord API
    • Send requests from any location, even a bot dashboard directly.
    • Don't send requests from dashboard to bot process to send a request to discord. Your bot process should be freed up to handle bot events!
  • Scalability! Scalability! Scalability!

Gateway

  • Zero Downtime Updates:
    • Others: With non-proxy bots, it takes about 5s per shard bucket to start up. With 100,000 servers, this would be minimum of 8+ minutes of downtime for bot updates.
    • Discordeno Proxy Gateway: Resume the bot code almost instantly without worrying about any delays or wasting your identify limits.
  • Zero Downtime Resharding:
    • Discord stops allowing your bot to be added to new servers when you max out your existing max shards. Consider a bot started with 150 shards operating on 150,000 servers. Your shards support a maximum of 150 * 2500 = 375,000 servers. Your bot will be unable to join new servers once it reaches this point until it re-shards.
    • DD proxy provides 2 types of re-sharding. Automated and manual. You can also have both.
      • Automated: This system will automatically begin a Zero-downtime resharding process behind the scenes when you reach 80% of your maximum servers allowed by your shards. For example, since 375,000 was the max, at 300,000 we would begin re-sharding behind the scenes with ZERO DOWNTIME.
        • 80% of maximum servers reached (The % of 80% is customizable.)
        • Identify limits have room to allow re-sharding. (Also customizable)
      • Manual: You can also trigger this manually should you choose.
        • When discord releases a new API version, updates your gateways to new version with no downtime.
  • Horizontal Scaling:
    • When your bot grows a lot, you have two options: you can either keep investing money to upgrade your server or you may expand horizontally by purchasing several more affordable servers. The proxy enables WS handling on multiple servers.
  • No Loss Restarts:
    • Without the proxy mechanism, you would typically lose a lot of events while restarting. Users could issue instructions or send messages that are not automoderated. As your bot grows, this amount grows sharply. Users who don't receive the automatic roles or any other activities your bot should do.
    • While your bot is unavailable, events can be added to a queue, and once the bot is back online, the queue will start processing all of the events.
  • Flexibility:
    • You have complete control over everything inside the gateway thanks to the controller aspect. Need to customize, the way the manager talks to the workers? Simply, plug in and override the method.
  • Clustering With Workers:
    • Utilize all of your CPU cores to their greatest potential by distributing the workload across workers. To enhance efficiency, manage how shards per worker.

Custom Cache

Have your cache setup in any way you like. Redis, PGSQL or any cache layer you would like.

Getting Started

Interested? Check the website for more details on getting started.

Links

Discordeno follows semantic versioning

Contributing/Developing

We use yarn as package manager and workspace manager, and turborepo as monorepo manager.

To config the workspace run

# if you don't have yarn installed
npm install -g yarn

yarn install

Then you can build all the files and types across all packages using (unless specified all commands below are run at root directory)

yarn release-build

You can run unit tests on all packages using

yarn test:unit

Other useful information are available on the website under the contributing documentation

Other useful scripts (if you run in the package's directory, you need build dist before for test and types before for lint/fmt. Running in root directory should automatically do it for you)

# check style
yarn lint

# format code
yarn fmt

# check type
yarn test:type

# check type for tests
yarn test:test-type

# unit test showing coverage
yarn test:unit-coverage

# unit test with Deno
yarn test:deno-unit

# integration test
yarn test:integration

# e2e test
yarn test:e2e

# build doc for website
yarn build:doc

discordeno's People

Contributors

8auu avatar afink avatar androz2091 avatar awesomestickz avatar ayntee avatar binotaliu avatar deepsarda avatar dependabot[bot] avatar endy3032 avatar evanwashere avatar existagon avatar fleny113 avatar h01001000 avatar itohatweb avatar livelove1987 avatar lts20050703 avatar matthewsh avatar meister03 avatar nsylke avatar quantumlyy avatar reboot-codes avatar skillz4killz avatar some-boi avatar suyashtnt avatar totothedragon avatar tricked-dev avatar triformine avatar vxern avatar yaikava avatar yuzudev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

discordeno's Issues

Voice Functionality

Is your feature request related to a problem? Please describe.
The library needs voice functionality for stuff like music bots.

Describe the solution you'd like
Need to research about voice functionality.

Describe alternatives you've considered
N/A

Additional context
N/A

Unable to create guild channel with specified channel type

Describe the bug
When creating a guild channel, a bad request is returned from discord.

To Reproduce
Steps to reproduce the behavior:

  1. When connected to a guild, create guild channel with specific type.
  2. See error

Expected behavior
Channel should be created without any issues.

Screenshots
image

Additional context
Using the latest release, 6.1.2.
I'm creating the channel specificly with type 2 for voice:

const newChannel = await createGuildChannel(guild, 'Random-voice-name', {
  type: ChannelTypes.GUILD_VOICE,
});

After some debugging, it looks like the error is here: https://github.com/Skillz4Killz/Discordeno/blob/master/handlers/guild.ts#L112

Output of the request body shows that it sends type: "GUILD_VOICE" instead of type: 2

Sharding Manager

We need a sharding manager.

My current thoughts on sharding is that ALL BOTS ARE SHARDED BOTS. There is no such thing as a non-sharded bot. Bot's under 1000 server can simply be placed in 1 shard. There is so much confusion for devs especially beginner developers around sharding or not sharding. By default, we will make all bots sharded to the recommended options that discord provides on initial connection.

We can take inspiration from Eris built in sharder and build a similar sharding solution. If and when a bot reaches a milestone like 25K servers we can help them use a custom sharding solution. That can bebuilt post v1? Basically imagine a eris-sharder but built into the lib in some way. As an official sharding solution for larger bots.

last note: At this time, deno has no support for clusters so im not sure how wed handle this yet at all. Should wait for deno to implement it i believe

Embed_Footer type is wrong.

Describe the bug
Embed_Footer has wrong property based Discord API. iconURL must be icon_url.

Screenshots
image
image

v9 Breaking Changes List

This issue is just a list of changes i notice that require changes but changing any of them would cause a breaking change. None of these are 100% essential to do but they give consistency and better user experience, so it's best to wait for a change that is 100% required and do all of these together.

  1. editChannel() requires a Channel. Change to guildID and channelID only.
  2. editChannel option to set slowmode still uses snake case.

Lack of usage of classes & event emitters

From the README:

  • Avoid as many headaches and issues related to class and this
  • Avoid EventEmitter to not have potential of memory leaks or bot crashes because of too many listeners or other silly issues.

Why?

V7 - To Do List

This issue is a list of changes that I need to make when a breaking change is required. This list is for breaking changes to the public api but it does not provide enough benefit to break everything asap. Once an important change warranting an update is made, this changes can also be added in.

  • Change createGuildRole() to createRole() as users were confused as seen in discord
  • Change kick(guild: Guild) to only require kick(guildID: string) this doesn't need the entire guild

Permissions Are Going Big Int!

Is your feature request related to a problem? Please describe.
All new permissions will require the permissions_new field. We need to switcharoo over to this asap incase a new perm is added for like the threads feature soon.
discord/discord-api-docs#1843

Describe the solution you'd like
Need to research a bit on this first to find the best solution

Describe alternatives you've considered
N/A

Additional context
N/A

Unit Tests

Is your feature request related to a problem? Please describe.
One of the big things missing in Discordeno, that I would like to have is Unit Testing.

Describe the solution you'd like
I want our unit testing to be very different from anything I have ever seen done in some others where they create a mock response for an api call. Ideally, I want our unit testing to be testing the actual api and not mocking it. Mocks although will make it faster make it unreliable and increases the load to maintain.

  1. Store a bot token in a github secret.
  2. Then using the CI i would try and run the bot which will be in a private test server that will trigger each & every function i want tested.
  3. Start by creating a new guild which gives it a fresh new clean environment.
  4. Create a role with custom options. (Review the roles structure to ensure it is accurate to the options we provided.)
  5. Create 1 channel for each channel type.
  6. Create a channel with a custom user permissions
  7. Create a channel with a custom role permission
    8... Etc... In essence the goal is to have every part of the lib tested with 100% confidence.

My only concern is testing like 100s of things can take time and it may cause the CI to take time determining if the build passes. However, i feel like having enough confidence to merge by waiting a few minutes before merging a PR would be worth it.

Note: Due to the amount of things that need to be done, the CI should only run when merging a PR to master branch.

Describe alternatives you've considered

  • Mock API

Additional context
https://deno.land/manual/testing

Logger

It would be nice to have a file that exports some of the colors as opposed to having to import it in all files. This would also allow end users of the lib to have a nice Logger as well!

import { blue, green, red, yellow } from "https://deno.land/std/fmt/colors.ts"
console.log(blue("< ping"));

Custom Caching

Is your feature request related to a problem? Please describe.
I think a way to have a custom cache would be incredible. For example, if i could implement Redis to store my cache.

Describe the solution you'd like
A cache provider perhaps that will accept methods for stuff like get set etc and then modify all the cache places.

Describe alternatives you've considered
NA

Additional context
Guild Member Update and Guild Member Remove issues found on Eris lib with intents.

OP 7 Handling

Describe the bug
OP 7 isn't being handled

To Reproduce
Start the bot wait for an OP 7.

Expected behavior
Resume the connection

Screenshots
image

Additional context
N/A

Rate Limit Manager

We need to implement a nice and clean easy to reuse rate limit manager. The goal will be to try and see if this rate limit manager can support across all shards and not just on 1 shard.

I believe the rate limit manager should exist on the Shard Manager itself and not on a shard or a client. The shard manager will contain all the shards and therefore the rate limiter can be set a bit better.

Thoughts? Alternatives?

[Docs] Add A Guide On Git Installation/Usage

Is your feature request related to a problem? Please describe.
Our current step by step guide, assumes that the end user has an understanding of git and has git installed but a lot of devs are first time devs when making bots. It is important to have a section where we show how to setup git.

Describe the solution you'd like

  • What is Git?
  • Installing Git
  • Cloning Your Discordeno Boilerplate repo

Describe alternatives you've considered
N/A

Additional context
N/A

getMessages Unit Test

Is your feature request related to a problem? Please describe.
Add a unit test for the getMessages function which can be found in src/handlers/channel.ts

Describe the solution you'd like

  1. create a new channel
  2. send 2 messages in this channel
  3. get those messages from cache or the return result this will be used later
  4. use the getmessages to get those message raw from the api
  5. compare all message default properties to make sure there are no issues when fetching a message raw

Additional context
Send PR to #109

Collection Class that extends Map

There are some important but useful methods that we would want to provide like filter or find on a map.

Note there should be NO way to prevent the caching. This is a key difference in our lib to try and meet the best of discord requirements. Cache what u can and give nothing back!

Get user not cached by name

Describe the solution you'd like
Function similar to getMember to get a member that isn't cached, but fetching it by it's username.

Issue Templates

We need to get some issue templates in place. Ideally, one for bugs, one for feature requests and one for questions

RESUME Functionality

Is your feature request related to a problem? Please describe.
Sometimes Discord API disconnects on occassion and we need to use the RESUME functionality to reinitiate a connection without losing any of the events from the last one being received. I have already finalized the s sequence number counter.

Describe the solution you'd like
Use Discords RESUME functionality

Describe alternatives you've considered
NA

Additional context
NA

The library errors out with Deno 1.0.1 +

Describe the bug
When trying to run a bot with updated Deno, it won't start.

To Reproduce
Try to upgrade Deno to the latest version (ATM, 1.0.2) and start the bot.

Andreys-MBP$ deno run --allow-read --allow-net --allow-env --unstable mod.ts 
error: Uncaught Error: Uncaught TypeError: Invalid URL.
    at WorkerImpl.#poll ($deno$/web/workers.ts:210:17)

A similar thing happens if I run the bot in Docker with Deno 1.0.1.
With 1.0.0, everything works as expected.

Expected behavior
The bot is to start and connect to Discord

Check if resume connection is possible

Describe the bug
Current the client try to always reconnection to gateway when we got a WebSocketCloseEvent:
https://github.com/Skillz4Killz/Discordeno/blob/d612af80d0f3d5d87d9dc3cdd6280e94cd7752a4/module/shard.ts#L109-L112

Expected behavior

We should determine if the connection need to resume but not always resume it.
Some error codes are not recoverable like 4012 Invalid API Version or 4013 Invalid Intent(s).

ref: https://discord.com/developers/docs/topics/opcodes-and-status-codes

getPins Unit Testing

Is your feature request related to a problem? Please describe.
Add a unit test for the getMessage function which can be found in src/handlers/channel.ts

Describe the solution you'd like

  1. create a new channel
  2. Send 3 messages
  3. Pin 2 messages
  4. Get pins
  5. Make sure the non-pinned message was not returned
  6. Make sure 2 messages were returned

Additional context
Send PR to #109

Create a good Events API.

This could either be with Observables, or something else. Let's think about it.

We need a system where users can listen to events.

processQueue() exceeds maximum call stack size

Describe the bug
Calling addReaction (or presumably other functions) to fast results in processQueue calling itself until it exceeds the stack size limit. Waiting a second between calls "solves" the issue.

To Reproduce
Steps to reproduce the behavior:

  1. run:
import Client from "https://raw.githubusercontent.com/Skillz4Killz/Discordeno/master/src/module/client.ts";
import { addReaction } from "https://raw.githubusercontent.com/Skillz4Killz/Discordeno/master/src/handlers/message.ts";
import { Intents } from "https://raw.githubusercontent.com/Skillz4Killz/Discordeno/master/src/types/options.ts";

Client({
	token: "<bot-token>",
	intents: [Intents.GUILD_MESSAGES, Intents.GUILDS, Intents.GUILD_MESSAGE_REACTIONS],
	eventHandlers: {
		ready: ()=>{console.log("Ready!");},
		messageCreate: async (m)=>{
			if (m.content === "!react") {
				addReaction(m.channelID,m.id,"๐Ÿ”ผ");
				addReaction(m.channelID,m.id,"๐Ÿ”ฝ");
				addReaction(m.channelID,m.id,"โ—€๏ธ");
				addReaction(m.channelID,m.id,"โ–ถ๏ธ");
			}
		}
	}
});
  1. send !react on discord
  2. crash:
error: Uncaught RangeError: Maximum call stack size exceeded
    const request = queue.shift();
                          ^
    at Array.shift (<anonymous>)
    at processQueue (requestManager.ts:39:27)
    at processQueue (requestManager.ts:60:21)
    at processQueue (requestManager.ts:60:21)
    at processQueue (requestManager.ts:60:21)
    at processQueue (requestManager.ts:60:21)
    at processQueue (requestManager.ts:60:21)
    at processQueue (requestManager.ts:60:21)
    at processQueue (requestManager.ts:60:21)
    at processQueue (requestManager.ts:60:21)

Expected behavior
No crash (and all reactions of the bot on discord)

Screenshots
chat-history in discord
Screenshot from 2020-08-09 19-50-56

Additional context
broken on branch: master

if I have enough time I want to clone the repo and try wrapping the recursive call into queueMicrotask (similar to process.nextTick in Node) or setTimeout.

Editing Bots Status

Question again, does Discordeno support Bot Statuses? All I can find related to that is the presenceUpdate property in Events so how would that be done?

I will also make a list of bugs I come across and once enough i'll make a bug report with them all, just to ease of the clutter of bug reports I make for each bug

Originally posted by @NTMNathan in discordeno/template#10 (comment)

Labels

We need some nice github labels to mark issues and pull requests.

Bot not starting up due to "[ERROR]: 'type' is specified more than once"

Describe the bug
So, i've created my own bot with Discordeno based from the template you have provided and customised it with my own liking. I've installed the newly released latest Deno Version, TypeScript and Discordeno version. However, when booting up the bot with the deno run --allow-read --unstable mod.ts or without the --unstable. I have ran into an error which resulted in:

ntmnathan:DenoBot ntmnathan$ deno run --allow-net --allow-read --unstable mod.ts
Compile file:///Users/ntmnathan/Documents/DenoBot/mod.ts
error: TS2783 [ERROR]: 'type' is specified more than once, so this usage will be overwritten.
          type: options.type ? ChannelTypes[options.type] : undefined,
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at https://raw.githubusercontent.com/Skillz4Killz/Discordeno/v1/structures/guild.ts:85:11

    This spread always overwrites this property.
              ...options,
              ~~~~~~~~~~
        at https://raw.githubusercontent.com/Skillz4Killz/Discordeno/v1/structures/guild.ts:93:11

I am not 100% sure if this is on my end or Discordeno's. Any help appreciated.

To Reproduce
Steps to reproduce the behaviour:

  1. Execute deno run --allow-net --allow-read --unstable mod.ts
  2. Error above will be produced

Expected behaviour
If the deno command above is executed in the bash console, it should make the bot authenticate with the API and go online.

Resources
If you want me to add screenshots/code. Let me know, but its similar to Discordeno example.

Additional context
None.

getMessage Unit Testing

Is your feature request related to a problem? Please describe.
Add a unit test for the getMessage fnction which can be found in src/handlers/channel.ts

Describe the solution you'd like

  1. create a new channel
  2. send a message in this channel
  3. get that message from cache or the return result this will be used later
  4. use the getmessage to get that message raw from the api
  5. compare all message default properties to make sure there are no issues when fetching a message raw

Additional context
Send PR to #109

[Vote]: Preferred Versioning System

Hello ๐Ÿ‘‹

This issue is just to collect feedback from users of this module to learn about how the 2 versioning system are taken by end users. If you prefer the SemVer versioning for this module leave a ๐Ÿ‘ on this issue and if you prefer the automated versioning system leave a โค๏ธ on this issue.

image

If you have any other comments feel free to leave them below as we go through this experiment on which versioning system is better for developers.

Note: Please only base your vote/opinions on this module alone. Do not base it on the industry standard or npm or node or anything. This experiment is to see how any developer would feel using this library in a versioning system without MINOR and PATCH system.

Event Handling

Since Deno does not have an EventEmitter, we need to somehow create a solution for this. The current idea i have as a rough first draft is that when an event is sent by discord through the websocket we just run a function on the client.

client.eventHandlers.guildMemberAdd() for example

This would allow the end users to overwrite the functions as they wish.

Snake Case

Hello ๐Ÿ‘‹

A few users have noted that they see some odd instances of snake case in the library and I wanted to take a minute to address it.

When I started this library my goal was to learn different things and try different things. Most of what I did in this lib is for me to experiment and learn. I realized how terrible it was to work with snake_case. This became quite problematic to use in the long run so I opted for camelCase. If I missed any that are still in snake_case I will 100% be correcting them.

If you see any please leave them in a comment below, I will keep this issue pinned for a while.

Note: Since this will be changing the public API for some methods/props, we will be making this as v2 branch once all of them have been fixed.

Incompatible with latest Deno / TS

Describe the bug
Discordeno is incompatible with latest Deno / TS

I saw a bunch of commits that are fixing this but there is no release for that so this issue is probably for the next person trying to figure out what they did wrong when the simple example won't work

Love the project btw ๐Ÿ™Œ

To Reproduce

deno --version
deno 1.3.2
v8 8.6.334
typescript 4.0.2

using the simple bot in the documentation

import Client from "https://x.nest.land/[email protected]/src/module/client.ts";
import { sendMessage } from "https://x.nest.land/[email protected]/src/handlers/channel.ts";
import { Intents } from "https://x.nest.land/[email protected]/src/types/options.ts";
import config from "./config.ts";
Client({
    token: config.token,
    intents: [Intents.GUILD_MESSAGES, Intents.GUILDS],
    eventHandlers: {
        ready: () => {
            console.log(`Logged!`);
        },
        messageCreate: (message) => {
            if (message.content === "!ping") {
                sendMessage(message.channel, "Pong");
            }
        }
    }
});
  1. run deno run --allow-net --allow-read mod.ts
  2. See error
error: TS2790 [ERROR]: The operand of a 'delete' operator must be optional.
  delete guild.owner_id;
         ~~~~~~~~~~~~~~
    at https://iwa2o57bd3gy7nzbtujtzyuhtqu4ytlinyytm57d6npp2o47npha.arweave.net/RYGnd-EezY-3IZ0TPOKHnCnMTWhuMTZ34_Ne_Tufa84/src/structures/guild.ts:73:10

TS2790 [ERROR]: The operand of a 'delete' operator must be optional.
  delete guild.afk_channel_id;
         ~~~~~~~~~~~~~~~~~~~~
    at https://iwa2o57bd3gy7nzbtujtzyuhtqu4ytlinyytm57d6npp2o47npha.arweave.net/RYGnd-EezY-3IZ0TPOKHnCnMTWhuMTZ34_Ne_Tufa84/src/structures/guild.ts:74:10

TS2790 [ERROR]: The operand of a 'delete' operator must be optional.
  delete guild.afk_timeout;
         ~~~~~~~~~~~~~~~~~
    at https://iwa2o57bd3gy7nzbtujtzyuhtqu4ytlinyytm57d6npp2o47npha.arweave.net/RYGnd-EezY-3IZ0TPOKHnCnMTWhuMTZ34_Ne_Tufa84/src/structures/guild.ts:75:10

TS2790 [ERROR]: The operand of a 'delete' operator must be optional.
  delete guild.verification_level;
         ~~~~~~~~~~~~~~~~~~~~~~~~
    at https://iwa2o57bd3gy7nzbtujtzyuhtqu4ytlinyytm57d6npp2o47npha.arweave.net/RYGnd-EezY-3IZ0TPOKHnCnMTWhuMTZ34_Ne_Tufa84/src/structures/guild.ts:78:10

TS2790 [ERROR]: The operand of a 'delete' operator must be optional.
  delete guild.mfa_level;
         ~~~~~~~~~~~~~~~
    at https://iwa2o57bd3gy7nzbtujtzyuhtqu4ytlinyytm57d6npp2o47npha.arweave.net/RYGnd-EezY-3IZ0TPOKHnCnMTWhuMTZ34_Ne_Tufa84/src/structures/guild.ts:79:10

TS2790 [ERROR]: The operand of a 'delete' operator must be optional.
  delete guild.system_channel_id;
         ~~~~~~~~~~~~~~~~~~~~~~~
    at https://iwa2o57bd3gy7nzbtujtzyuhtqu4ytlinyytm57d6npp2o47npha.arweave.net/RYGnd-EezY-3IZ0TPOKHnCnMTWhuMTZ34_Ne_Tufa84/src/structures/guild.ts:80:10

TS2790 [ERROR]: The operand of a 'delete' operator must be optional.
  delete guild.vanity_url_code;
         ~~~~~~~~~~~~~~~~~~~~~
    at https://iwa2o57bd3gy7nzbtujtzyuhtqu4ytlinyytm57d6npp2o47npha.arweave.net/RYGnd-EezY-3IZ0TPOKHnCnMTWhuMTZ34_Ne_Tufa84/src/structures/guild.ts:83:10

TS2790 [ERROR]: The operand of a 'delete' operator must be optional.
  delete guild.premium_tier;
         ~~~~~~~~~~~~~~~~~~
    at https://iwa2o57bd3gy7nzbtujtzyuhtqu4ytlinyytm57d6npp2o47npha.arweave.net/RYGnd-EezY-3IZ0TPOKHnCnMTWhuMTZ34_Ne_Tufa84/src/structures/guild.ts:84:10

TS2790 [ERROR]: The operand of a 'delete' operator must be optional.
  delete guild.premium_subscription_count;
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at https://iwa2o57bd3gy7nzbtujtzyuhtqu4ytlinyytm57d6npp2o47npha.arweave.net/RYGnd-EezY-3IZ0TPOKHnCnMTWhuMTZ34_Ne_Tufa84/src/structures/guild.ts:85:10

TS2790 [ERROR]: The operand of a 'delete' operator must be optional.
  delete guild.preferred_locale;
         ~~~~~~~~~~~~~~~~~~~~~~
    at https://iwa2o57bd3gy7nzbtujtzyuhtqu4ytlinyytm57d6npp2o47npha.arweave.net/RYGnd-EezY-3IZ0TPOKHnCnMTWhuMTZ34_Ne_Tufa84/src/structures/guild.ts:86:10

TS2790 [ERROR]: The operand of a 'delete' operator must be optional.
  delete guild.joined_at;
         ~~~~~~~~~~~~~~~
    at https://iwa2o57bd3gy7nzbtujtzyuhtqu4ytlinyytm57d6npp2o47npha.arweave.net/RYGnd-EezY-3IZ0TPOKHnCnMTWhuMTZ34_Ne_Tufa84/src/structures/guild.ts:87:10

TS2790 [ERROR]: The operand of a 'delete' operator must be optional.
  delete guild.voice_states;
         ~~~~~~~~~~~~~~~~~~
    at https://iwa2o57bd3gy7nzbtujtzyuhtqu4ytlinyytm57d6npp2o47npha.arweave.net/RYGnd-EezY-3IZ0TPOKHnCnMTWhuMTZ34_Ne_Tufa84/src/structures/guild.ts:89:10

TS2790 [ERROR]: The operand of a 'delete' operator must be optional.
  delete message.channel_id;
         ~~~~~~~~~~~~~~~~~~
    at https://iwa2o57bd3gy7nzbtujtzyuhtqu4ytlinyytm57d6npp2o47npha.arweave.net/RYGnd-EezY-3IZ0TPOKHnCnMTWhuMTZ34_Ne_Tufa84/src/structures/message.ts:26:10

TS2790 [ERROR]: The operand of a 'delete' operator must be optional.
  delete message.mentions_everyone;
         ~~~~~~~~~~~~~~~~~~~~~~~~~
    at https://iwa2o57bd3gy7nzbtujtzyuhtqu4ytlinyytm57d6npp2o47npha.arweave.net/RYGnd-EezY-3IZ0TPOKHnCnMTWhuMTZ34_Ne_Tufa84/src/structures/message.ts:28:10

TS2790 [ERROR]: The operand of a 'delete' operator must be optional.
  delete message.mention_roles;
         ~~~~~~~~~~~~~~~~~~~~~
    at https://iwa2o57bd3gy7nzbtujtzyuhtqu4ytlinyytm57d6npp2o47npha.arweave.net/RYGnd-EezY-3IZ0TPOKHnCnMTWhuMTZ34_Ne_Tufa84/src/structures/message.ts:30:10

TS2790 [ERROR]: The operand of a 'delete' operator must be optional.
  delete message.edited_timestamp;
         ~~~~~~~~~~~~~~~~~~~~~~~~
    at https://iwa2o57bd3gy7nzbtujtzyuhtqu4ytlinyytm57d6npp2o47npha.arweave.net/RYGnd-EezY-3IZ0TPOKHnCnMTWhuMTZ34_Ne_Tufa84/src/structures/message.ts:33:10

TS2790 [ERROR]: The operand of a 'delete' operator must be optional.
    delete headers["Content-Type"];
           ~~~~~~~~~~~~~~~~~~~~~~~
    at https://iwa2o57bd3gy7nzbtujtzyuhtqu4ytlinyytm57d6npp2o47npha.arweave.net/RYGnd-EezY-3IZ0TPOKHnCnMTWhuMTZ34_Ne_Tufa84/src/module/requestManager.ts:157:12

Found 17 errors.

Expected behavior
No TS errors thrown in the console

Additional context
Tested on 8.0.0 8.2.2 and 7.3.0

channelOverwriteHasPermission Unit Testing

Is your feature request related to a problem? Please describe.
Add a unit test for channelOverwriteHasPermission function which can be found inside the src/handlers/channel.ts file.

Describe the solution you'd like

  1. Create a new role
  2. Create a channel with a set of permissions being granted and denied to this role
  3. Check if this role has a permission in this channel overwrite
  4. confirm that it denies permission for a permission the role does not have
  5. Check if it also denies for a permission that was neither granted nor denied

Additional context
Please send PR to #109

sendMessage Unit Test

Is your feature request related to a problem? Please describe.
Add a unit test for the sendMessage function which can be found in src/handlers/channel.ts.

There should be several tests for this imo for all the different types of options available.

Describe the solution you'd like

  1. create a new channel
  2. send a message with some content
  3. Send an embed with each prop
  4. Send an embed with an attachmane
  5. send an attachment
  6. Test sending with mentions

Additional context
Send PR to #109

Code Of Conduct

Need to add in a code of conduct to meet community checklist!

Save logs in .log extension

Is your feature request related to a problem? Please describe.
Sometimes I want to see a complete logs but not able to see because of my vps. Whenever it restarts it clear the console values.

Describe the solution you'd like
If logger save all the logs passed through it in a .log extension like Winston then it will be great.

Additional context
Not really a must feature but it will be a cool feature available here.

Compression

Is your feature request related to a problem? Please describe.
We should enable the ability to have GZIP compression from discord to decrease bandwidth used when sending data

Describe the solution you'd like
I think Deno implemented gzip compression
denoland/deno#3597

Describe alternatives you've considered
NA

Additional context
NA

[Docs] Add a Guide On Github

Is your feature request related to a problem? Please describe.
The current guide requires that the user have knowledge and understanding of Github but not all users do. It would be nice to have a page dedicated to teaching end users about github.

Describe the solution you'd like

  • What is Github?
  • Create An Account on Github
  • Create An Issue on Discordeno Repo
  • Create A Pull Request On Discordeno Repo

Describe alternatives you've considered
N/A

Additional context
N/A

Voice events does not work as expected

Describe the bug
Abnormalities in voice events. I've set up 3 events, joined, left and switched voice channels.
It looks like it doesn't update the current voice channel for a given user.

By the looks of the events, I also assume the current voice channels are somewhat cached, which is not updated at all places. But can't tell for sure

To Reproduce
Steps to reproduce the behavior:

  1. Join VC 1. (Join VC 1 event emitted)
  2. Leave VC 1. (Leave VC 1 event emitted)
  3. Join VC 2. (No join event is emitted, but switch from VC 1 to VC 2 is emitted)
  4. Join VC 1. (No events are emitted)
  5. Join VC 2. (Switch from VC 1 to VC 2 event is emitted)
  6. Leave VC 2. (Leave VC 1 event emitted, not VC 2)

Expected behavior
Expect to see correct join and leave events.

Screenshots
image

Additional context
Using the latest v6 branch

Fundamental design goals for V1

Fundamental Design Goals

This document serves to outline the overall design goals of the project. Please see below a list of these fundamentals.

Do not allow anything Discord does not permit

Prevent any and all attempts of making user bots. If someone connects and the client.user is not a bot user then throw an error immediately.

Do not support non-bot features like Group DMs or dm calls etc...

Prettier Philosophy Regarding Options

Avoid options/customizable whenever possible. Always enforce default values. Except in cases like intents where the user should be able to pick which intents to listen for.

Security

Permission checks should be done by the library! We can throw a custom error that shows which permissions are missing in order to run this request and save an API call. This will also prevent bots from getting banned due to Missing Access errors.

Typescript 3.8 provides TRUE private props and methods that no one can access. We will use this to our advantage to truly make a proper API. This isn't a silly _ to mark it as a private but the user should NEVER be able to access it no matter what.

Functional API

Events emitted by the client, for example the message creation event, should not emit a Message class instance, but instead a POJO (Plain Ol' JavaScript Object). This will overall make a cleaner and more performant API, while removing the headaches of extending built-in classes, and inheritance.

Use functions when possible instead of an event emitter to prevent emitter related memory leak issues or a number of other headaches that arise.

TLDR: Avoid classes whenever possible. Avoid loops whenever possible(opt for iterations like .forEach, map reduce, some find etc...)

Documentation

Use /** Description here */ comments above all properties and methods to describe it so that VSC and other good IDE's with intellisense can pick it up and provide the documentation right inside the IDE preventing a developer from needing Discord API docs or even Deno documentation.

We should have a step by step guide nonetheless but this is a POST v1 launch.
We should have a template repo to creating a boilerplate bot.

Backwards Compatibility BS

Backwards compatibility is the death of code. It causes clutter and uglyness to pile up and makes developers lazier. There will be no such thing as backwards compatibility reasons in Discordeno. We will always support the latest and greatest of JS. The end! Users can fork the lib at any commit to keep older versions until they are ready to update.

That said, we don't expect many things to be changing drastically after v1. As you can imagine Typescript allows the latest and greatest of JS so we will be ahead of the curve for years to come.

Style Guide

Prettier is our style guide. No discussions around styling ever. The options are set and that is all. When you code let prettier handle the styling. PERIOD!

Case Styles

Always use user_id casing instead of userId or UserID or userID. _ for all! ๐ŸŽ‰

Feel free to append goals as you see fit.

Support Bot Repo Stack Tracing

Is your feature request related to a problem? Please describe.
It would be nice to have error stacks from the bots own repo as opposed to the library. This helps determine what line of code from the user's own code is causing the error.

Describe the solution you'd like
The issue i made in deno has been solved and the PR is merged. It is releasing in 1.0.3 in deno and this needs to be added in.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.