Giter Club home page Giter Club logo

discord-bot's People

Contributors

astahmer avatar ayoubqrt avatar dilaouid avatar djang0dev avatar luca-montaigut avatar neolectron avatar potb avatar renovate[bot] avatar scttpr avatar tonykero avatar yanzi-dev avatar

Stargazers

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

Watchers

 avatar  avatar

discord-bot's Issues

The bot do not work after ~40min dev time

After working on the bot for a while, the function that push the commands do stale indefinitely.

The Rest.put call that push all commands blocks, and I believe we do get timeout by discord for doing that so often. (each code reload)

Proposal

Use Rest.get to get all commands schemas and diff with the one we have locally,
if nothing change: don't push,
if a command schema change: push only the changed command.

quoiFeur game doesn't mute correctly

Problem

The quoiFeur game has 1/20 chance to respond with coubeh, it mutes you whenever it happens.
The muting strategy goes with adding a role Muted to the user, which we remove after 15min.
This have many edge-cases such as:

  • one time, the role was deleted and not re-created (cache miss?)
  • it makes uses of setTimeout, so when the bot reload we have to clear the role
  • Moderators are most of the time above the muted role, so it doesn't work for them
  • We have to keep track of a role, give it some defaults, etc..

Solution

Use native timeout feature by discord (found by @smaiill on discord, thx).
It would solve many of the issues above, while also simplifying the code.
Here is the link to discord.js documentation for that.
image

Drawbacks

I think there is no such thing as beeing timeout in only one channel.
But considering the low duration of the timeout, and the amount of benefits, I think it's a good tradeoff.

Modules abstraction is leaking

Problem

I've notices that even after the new module abstraction we still have to wire some of the stuff outside of the module.

to name a few :

  • environment variables schema in src/config.ts
  • cache keys in src/core/cache.ts
  • intents in main.ts - fixed by #55

Solution

To fix the leaky abstraction, we should allow users to provide this configuration within the scope of their module.

I'm keen into taking a shot at this next time I work on the bot.

Modules throws crash the whole bot.

Today a module had crashed the whole bot.

I thought that the throw boundary was scoped to the client.on but maybe not.
We should check this.
image

I don't want to FORCE users to catch inside modules, although it's a good practice, a module should only crash itself. Bonus if it goes into disabled state after crashing.

fix: slash command handler subcommands keys aren't type-safe

Problem

Subcommands keys aren't typechecked.

{
  schema: new SlashCommandBuilder()
    .setName('myCommand')
    .addSubcommand((subcommand) =>
      subcommand.setName('subcommand1').setDescription('do 1'),
    )
    .addSubcommand((subcommand) =>
      subcommand
        .setName('subcommand2')
        .setDescription('do 2'),
    )
    .toJSON(),
  handler: {
    somethingNotLegit: async (interaction) => {},
    anyKeyCanBeHere: async (interaction) => {},
	// ^ ------------ Not legit
  },
}

Solution

Override the type of schema with subcommands strings as const (or check if they aren't in the type already). Then retrieve the subcommands keys with a type helper.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • chore(deps): update all dependencies (@types/node, @typescript-eslint/eslint-plugin, @typescript-eslint/parser, node, vitest)

Detected dependencies

docker-compose
docker-compose.yaml
  • redis 7.2.3-alpine
dockerfile
Dockerfile
  • node 21.4.0-alpine
  • node 21.4.0-alpine
github-actions
.github/workflows/deployment.yaml
  • actions/checkout v4
  • docker/setup-qemu-action v3
  • docker/setup-buildx-action v3
  • akhileshns/heroku-deploy v3.12.14
  • docker/build-push-action v5
  • ubuntu 22.04
.github/workflows/integration.yaml
  • amannn/action-semantic-pull-request v5
  • actions/checkout v4
  • docker/setup-qemu-action v3
  • docker/setup-buildx-action v3
  • pnpm/action-setup v2.4.0
  • actions/setup-node v4
  • docker/build-push-action v5
  • ubuntu 22.04
  • ubuntu 22.04
npm
package.json
  • @keyv/redis 2.8.1
  • cheerio 1.0.0-rc.12
  • constant-case 3.0.4
  • cron 3.1.6
  • discord.js 14.14.1
  • keyv 4.5.4
  • open-graph-scraper 6.3.2
  • param-case 3.0.4
  • zod 3.22.4
  • @types/node 20.10.4
  • @typescript-eslint/eslint-plugin 6.14.0
  • @typescript-eslint/parser 6.14.0
  • dotenv 16.3.1
  • eslint 8.56.0
  • eslint-import-resolver-typescript 3.6.1
  • eslint-plugin-import 2.29.1
  • eslint-plugin-only-error 1.0.2
  • eslint-plugin-simple-import-sort 10.0.0
  • eslint-plugin-sonarjs 0.23.0
  • eslint-plugin-unused-imports 3.0.0
  • npm-run-all 4.1.5
  • prettier 3.1.1
  • tsup 8.0.1
  • type-fest 4.8.3
  • typescript 5.3.3
  • vitest 1.0.4
  • node 21.4.0
  • pnpm 8.12.1
nvm
.nvmrc
  • node 21.4.0

  • Check this box to trigger a request for Renovate to run again on this repository

Reduce the friction for new dev to make a contribution

In order to reduce the initial setup to work on the project, I think REDIS_URL env should be optional in development (not prod).

If there's no redis URL the keyv library do use in-memory storage by default.

It would also allow contributors to quickly setup the project even without having docker on their machine.
It might drive more contributors as it would be really fast to have your project up and running.

Actions triggered by events don't work together

The way we handle events right now makes performing multiple actions at the same time difficult.

For example, when we post a twitter link in an autothread channel, the link won't be replaced by a vxtwitter one.

Maybe we can look into a sequential way of handling our events, using an array of handlers for example.

Remove DISCORD_GUILD_ID from env.

Problem

We need the bot to work on any server he's invited on.
One instance could be invited to multiple servers, and if some code look into this, it could lead to unexpected behavior.

Solution

Wherever we used this guild ID, we should just loop over every guild the discord is in.

Necessary environment variables are not clear

Right now, when the bot crashes due to missing environment variables, the user ends up with a cryptic zod error.
It's quite hard to understand which environment variables are missing.

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.