codinglab-io / discord-bot Goto Github PK
View Code? Open in Web Editor NEWDiscord bot for Codinglab's server.
Home Page: https://discord.com/invite/codinglab-174169014568878080
License: MIT License
Discord bot for Codinglab's server.
Home Page: https://discord.com/invite/codinglab-174169014568878080
License: MIT License
It's been 2 days since the recurring message in #blabla is fired twice.
We did setup it only once.
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)
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.
for the game "quoiFeur" we do use emoji to reply, we store all of them in an array.
We could have a function that takes an alphanumeric string and returns the emoji string.
Idea comes from the guide :
https://discordjs.guide/popular-topics/faq.html#why-do-some-emojis-behave-weirdly
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:
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.
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.
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 :
src/config.ts
src/core/cache.ts
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.
Now that we name the modules for logging it would be good to ensure that the module names are unique
it should.
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.
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.
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
},
}
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.
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates are awaiting their schedule. Click on a checkbox to get an update now.
@types/node
, @typescript-eslint/eslint-plugin
, @typescript-eslint/parser
, node
, vitest
)docker-compose.yaml
redis 7.2.3-alpine
Dockerfile
node 21.4.0-alpine
node 21.4.0-alpine
.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
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
.nvmrc
node 21.4.0
I looked on the original summarizer website, and the API didn't changed.
It's sure that now there is a domain restriction on their backend ๐ซ
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.
๐คทโโ๏ธ
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.
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.
Wherever we used this guild ID, we should just loop over every guild the discord is in.
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.
Using voice on demand, when someone is in a generated channel, and someone else leaves his generated channel, both are removed !
When you type /voice-on-demand create
on any other discord server, it will override the lobbyID in redis, which makes ultimately the command only work on one server.
We had an issue where a dependency from devDependencies was used in production code.
Let's add a plugin to avoid doing that again.
To check : eslint-plugin-import
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.