mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
BREAKING: node migration + major improvements and style changes (#2783)
* Setup turborepo (#2610) * chore: BREAKING move to monorepo structure * chore: setup turborepo * setup more eslint and tsconfig (#2612) * fix packages setting lcoation * add dist to ignore * style * fix: .vscode set prettier and remove deno configs (#2611) * fix: rewrite to process.env * chore: add node types * style: run eslint --fix * fix: tests import ext * chore: fix formatter * chore: add build script * chore: remove site from turborepo * chore: move to seperate packages * chore: seperate util * chore: rename to index * fix: utils * chore: bump typescript * fix: in process of fixing rest * fix: logger * style * chore: fix turbo script * fix: types * fix: types * fix: shard * fix: gateway * fixing: bot * fix: at least it can run now * chore: fix turbo script * chore: move plugins * chore: add type and utils export * chore: working bot type and cache plugin * Add git hooks (#2618) * CI: Setup ci (#2669) * ci: fix test * ci: fix typo * fix: turbo script * fixes: yarn and linter errors in embeds pkg * chore: fix yarn gitignore * Node migration - devcontainer (#2672) * ✨ - feat: devcontainer -> node * 👷♂ - ci: devcontainer - add tabnine, prettier * fix: ignore .env and debug.ts * fix: couple of linter errors * fix: linter error * fix: gateway linter errors * style: update style * style: fix bot style * fix: type * ci: move all old workflow * chore: close #2619 * chore: close #2671 * test: add mocha * chore: add typescript plugin * test: add mocha * test: add test to utils * test/ci: update ci and coverage * chore: change script naming * ci: update include test * test: add coverage * ci: fix cache * ci: fix ci and codecov * Discordeno Documentation (#2673) * Add git hooks * Add documentation generatation * Change Documentation Engine * Add documentation * Remove autogenerated docs * combine lint staged action into one * style: fix Co-authored-by: H01001000 <heiheiho000@gmail.com> * chore: new package client * test: add rest test * ci: enable codecov * fix: type * test: add test to all packages * ci: add release to gh per commit * fix: ci syntax * fix: package version * fix: publish script * fix: remove private from gateway * ci: add filter for changes * fix: ci syntex * ci: try fix path filter * ci: try fix path filter * test: add test * ci: fix string and boolean * fix: package and ci * chore: fix turbo type cache * ci: also publish to npm * ci: change to public * fix: not publish to npm * fix: dependencies * chore: fix fmt script * fix: better rest typecheck Closes #2621 * fix: run yarn install * feat: add transformers to rest * feat: add helpers to rest * test: move bot utils test * reverse change to release.yml * chore: add clean build * refactor: discordeno * chore: add import type * chore: remove bot * fix: change deps from bot to dd * chore: update yarn lock * test: temp remove test from logger * refactor: remove transformers in helpers/channel * type: close #2622 * ci(fix): explicitly define coverage file * refactor: remove transformers in helpers/emoji * type: fix discord guild type * feat: DiscordEditAutomoderationRule type * fix: remove unused type * feat: DiscordCreateGuildEmoji DiscordModifyGuildEmoji & DiscordModifyCHannel types * feat: DiscordCreateChannel DiscordBuDeleteMessages DiscordCreateMessage DiscordEditMessage * feat: DiscordCreateScheduledEvent EditScheduledEvent DiscordCreateInvite * fix: types for guild stuff for rest * feat: thread discord types for rest * feat: channel rest types * feat: member rest types * feat: more discord rest types * fix: type errors * fix: docs bot param name should be rest * type: fix type error * ci(fix): codecov * chore(client) :add export transformer * fix: verifySignature * test: fix types * test: add test prevent #2683 #2678 * fix: export transformer twice * ci: reuse cache * test: add test:unit-noTextCoverage * feat: add transform and constant package * fix: half fix #2683 #2688 * fix: #2688 fix all transformer.spec.ts * fix: transformer name * ci: update style * fix: dependencies * fix: naming * fix: yarn lock * fix: remove validations from helpers. Closes #2700 * fix: rest routes as a constants pkg * fix: esm import with .js * test: add exception case * feat: adding transformer * chore: change script name * chore: add path fixing to coverage file * fix: camelize tuple bug * fix: reverse transformers * fix: transformers folder to camel * fix: transformers as an object * fix: linter error * ci: run test with deno close #2701 * fix: test depends on build * fix: deno import node:crypto * fix: rest improvements * fix: channel type * fix: export user * chore: move to unit dir * test: moving bench * fix: remove transformers from rest package * fix: move toggle transformers to bot pkg * fix: move out gw helpers to gw package * test: add rest e2e test * fix: syntex * ci: add discord token * fix: ci not passing secret * test: add role test * ci: fix secret inherit * fix: role helpers transformer * test: increase timeout to 10s * fix: member helpers transformer * test: add member test * fix: name and type * fix: guild ban * test: fix test * fix: test add await * test: skip some test * test: increase timeout * chore: add transformer to import map * fix: test * test: add why-is-node-still-running * test: add debug hook * ci: add timeout incase any async running * test: try fix * test: turn on rest debug * fix: if undefined * test: reduce timeout * fix: queue not running after some request * fix: increase remaining after request without ratelimit header * fix: partial webhook * fix: fetch hooks not working if debug defined later * fix: nickname null to undefined * test: finish adding webhook test * refactor(test): move rest to utils * fix: add await * fix: sticker * feat: add message embed component transformer * fix: test not done * fix: arg type to bigString * fix: sendMessage * fix: add allowedMentions, interactionResponse * test: add emoji e2e test * test: add guild e2e test * refactor(test): remove extra rest call * fix: create emoji BINARY_TYPE_INVALID_DATA_URI * fix: create guild rate limit * fix: automode rule helpers and test * fix: test run in only * test: add some queue bucket test * test: remove empty test * refactor(test): use new guild * test: use new guild for other test * fix: guild not defind * reactor(test): remove duplicated creat channel * test: increase timeout to 30s * test: add thread test * fix: more transformers * fix: gateway helpers use transformers * fix: types belong in types pkg * fix: helpers use transformers * BREAKING: v19 rewrite to node + major improvements (#2703) * fix: move all to old folder * fix: cleanup types * fix: more cleanup * fix: more base cleanup * fix: token dotenv * fix: add base transformer * fix: partial error handling * fix: handle 429 rate limit * test(rest): fix unit test * fix(script): transform extension * test: fix error and buffer * feat: camelizer util * fix: cleanup * fix: rate limit queues and headers processing * fix: rest exports * fix: no more transformers * fix: queue header null bug * fix: add gateway package base * fix: lint error * fix: add prettier file * fix: prettier is default fmtr * fix: fmt shard file * fix: fmt * fix: types issue * fix: remove unused consts * fix: all import issues * fix: import error * fix: import ending with .js * fix: remove transformers package * Fix eslint (#2710) * fix: typing of button component label to be optional (#2708) * feat: add guild_connections to role tags and toggles (#2706) Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> * Add lint checks and autofixing workflow (#2702) * Add lint checks and autofixing workflow * Update lint.yml * Fix: use yarn instead npm * fix: add ts to eslint_extensions * fix: update dir * fix: lint.yml format Co-authored-by: Jonathan Ho <heiheiho000@gmail.com> * fix: unused deps * ci: fix e2e test not running * chore: run yarn install * test: this should run test * feat: getCHannel * feat: createEMji helper * feat: collection class in util package * fix: gateway bugs * why on earth is this needed change * fix: cleanup docs on collection * Emoji rest methods (node-migration-clean) (#2713) * feat: all emoji rest methods * Fix code style issues with ESLint Co-authored-by: Lint Action <lint-action@samuelmeuli.com> * fix: stuff * fix: bot types * fix: remove logs * fix: camelize all gateway payloads * fix: remove todos * fix: start deris * fix: lint/ts errors except shard file * thats 1 way to fix type errors * yes (#2714) Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> * feat: rest channel helpers * Update release.yml * Update release.yml * ci: add build filter * ci: fail fast false * fix: complete webhook related helpers * fix: follow announcement helper * add forum helper * add stage helpers * add thread related helpers * alphabetize * cleanup webhook routes * automod helpers * scheduled events * integrations helpers * invite stuff incomplete * dm channel and avatar url * chore: move ts-node into package * fix: importing esm * fix: tris message helpers * test(rest): add simplifyUrl test * test(rest): add checkRateLimits test * test(rest): add processRateLimitedPaths test * test(rest): fix missing beforeEach * test(utils): enable old test * interaction helpers * perf(utils): optimize snake to camel case conversion (#2717) * perf(utils): optimize snake to camel case conversion * fmt * wont change much but still faster * actually this was a stupid idea * shh * Fix(client): Fix typings. (#2716) Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> * test: fix rest and utils test (#2723) * test(utils): fix cant import collection * test(rest): await expect * fix(utils): deno compactability * test(utils): typing * fix(utils): add return type * Add rest helpers for templates (#2727) * Add rest helpers for templates * Fix code style issues with ESLint Co-authored-by: Lint Action <lint-action@samuelmeuli.com> * fix: remove frozenAt * fix: cleanup templates * ci: release to npm (#2725) * ci: release to npm * Update release.yml * 🐛 - fix: types - slashcommands - add nsfw prop (#2731) * feat(rest helpers): Add template and member helpers. (#2728) * feat(rest helpers): Add template and member helpers. * format code * feat(rest): add template routes * fix(rest): routes and runMethod * fix(rest): try to fix most of type Co-authored-by: H01001000 <heiheiho000@gmail.com> Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> * ci: fix release (#2732) * fix: rest type errors * fix: v19 begin * fix: yarn lock * chore: fix deps and script (#2733) * fix: bug camelizer deleting letters * fix: falsy token check * fix: add frozenat check for queue * fix: max stack trace error do to infinite loop * fix: type error * test(rest): fix missing import (#2734) Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> * fix: file paths for imports * fix: lastShardId should default to 0 * fix: use isomorphic ws * test(rest): fix "TypeError: [Function] is not a thenable" (#2736) * test(utils): add utils tests (#2737) * test(utils): add urltobase64 test * test(utils): add token test * test(utils): fix missing import buffer * test(utils): add casting test * test(utils): add casting test * test(utils): fix use correct function * chore: make eslint error if missing .js extension (#2735) * chore: eslint error if missing .js extension * chore * lint: fix missing .js error Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> * fix: readme runtime list (#2739) * Bot pkg (#2740) * fix: bot pkg test * Fix code style issues with ESLint * Update Guild.ts * Update Guild.ts * Fix code style issues with ESLint Co-authored-by: Lint Action <lint-action@samuelmeuli.com> Co-authored-by: Jonathan Ho <heiheiho000@gmail.com> * Update tsdoc.json (#2741) Updates tsdoc.json to reflect the current packages. * Interaction types - remove member,channel,role from value type (#2743) https://discord.com/channels/785384884197392384/1067265182776176690/1068189883073572924 * Add missing types (#2742) * Revert "fix: use isomorphic ws" (#2744) This reverts commitad306b0d0a. * fix: interaction requests that sent without full url * fix: lint issues * fix: remote gateway test file * fix: interaction response bug with body being invalid (#2746) * fix: readme runtime list * Fix code style issues with ESLint * node 18 * fix: websocket import type * fix: body for interaction requests --------- Co-authored-by: Lint Action <lint-action@samuelmeuli.com> * fix: interaction followup type (#2747) * fix: readme runtime list * Fix code style issues with ESLint * node 18 * fix: websocket import type * fix: body for interaction requests * fix: perma fix for type error in ci * fix: followupmessage option type --------- Co-authored-by: Lint Action <lint-action@samuelmeuli.com> * fix: e2e exit bug (#2748) * fix: readme runtime list * Fix code style issues with ESLint * node 18 * fix: websocket import type * fix: body for interaction requests * fix: perma fix for type error in ci * fix: followupmessage option type * fix: e2e tests exit bug * fix: color console logger --------- Co-authored-by: Lint Action <lint-action@samuelmeuli.com> * fix: rest sending attachments files (#2749) * fix: readme runtime list * Fix code style issues with ESLint * node 18 * fix: websocket import type * fix: body for interaction requests * fix: perma fix for type error in ci * fix: followupmessage option type * fix: e2e tests exit bug * fix: color console logger * fix: image file sending * Fix code style issues with ESLint --------- Co-authored-by: Lint Action <lint-action@samuelmeuli.com> * fix: guild and role methods (#2751) * fix: readme runtime list * Fix code style issues with ESLint * node 18 * fix: websocket import type * fix: body for interaction requests * fix: perma fix for type error in ci * fix: followupmessage option type * fix: e2e tests exit bug * fix: color console logger * fix: image file sending * Fix code style issues with ESLint * guild and role methods * Fix code style issues with ESLint --------- Co-authored-by: Lint Action <lint-action@samuelmeuli.com> * ci: add bot package (#2752) * ci: add bot package * ci: fix test * e2e test stuff (#2754) * fix: readme runtime list * Fix code style issues with ESLint * node 18 * fix: websocket import type * fix: body for interaction requests * fix: perma fix for type error in ci * fix: followupmessage option type * fix: e2e tests exit bug * fix: color console logger * fix: image file sending * Fix code style issues with ESLint * guild and role methods * Fix code style issues with ESLint * fix: dont send heartbeat if socket is not open * fix: remove logs * fox: remove more logs * fix some bugs in role tests * Switch to after hook style * hoti's speed snaker * auto convert objects for discord * Fix code style issues with ESLint * fix: remove dup imports * fix: i hate linters * speeder --------- Co-authored-by: Lint Action <lint-action@samuelmeuli.com> * fix: delete guilds test (#2758) * fix: readme runtime list * Fix code style issues with ESLint * node 18 * fix: websocket import type * fix: body for interaction requests * fix: perma fix for type error in ci * fix: followupmessage option type * fix: e2e tests exit bug * fix: color console logger * fix: image file sending * Fix code style issues with ESLint * guild and role methods * Fix code style issues with ESLint * fix: dont send heartbeat if socket is not open * fix: remove logs * fox: remove more logs * fix some bugs in role tests * Switch to after hook style * hoti's speed snaker * auto convert objects for discord * Fix code style issues with ESLint * fix: remove dup imports * fix: i hate linters * speeder * fix: tests delete guilds * Fix code style issues with ESLint --------- Co-authored-by: Lint Action <lint-action@samuelmeuli.com> * chore: fix deps (#2757) * ci/test: fix bot pkg e2e test (#2759) * chore: fix script and update import map (#2761) * chore: fix version script * chore: update import map * chore: fix ws import map * chore: fix deno import map * test: fix * fix: more rest e2e tests (#2763) * fix: readme runtime list * Fix code style issues with ESLint * node 18 * fix: websocket import type * fix: body for interaction requests * fix: perma fix for type error in ci * fix: followupmessage option type * fix: e2e tests exit bug * fix: color console logger * fix: image file sending * Fix code style issues with ESLint * guild and role methods * Fix code style issues with ESLint * fix: dont send heartbeat if socket is not open * fix: remove logs * fox: remove more logs * fix some bugs in role tests * Switch to after hook style * hoti's speed snaker * auto convert objects for discord * Fix code style issues with ESLint * fix: remove dup imports * fix: i hate linters * speeder * fix: tests delete guilds * Fix code style issues with ESLint * fix: easier to provide custom intents in bot * fix: shutdown bot after test * fix: add getGuild * fix: multiple guild delete attempts * fix: add emoji e2e tests * fix: remaining old e2e rest tests * Fix code style issues with ESLint --------- Co-authored-by: Lint Action <lint-action@samuelmeuli.com> * test: add gateway integration test (#2756) * test: add gateway integration test * test(gateway): fix connection test * test(gateway): add heartbeat test * ci: add integration test * fix: add uWebSockets.js * ci: add timeout * test(utils): remove old test * Revert "test(utils): remove old test" This reverts commit04fb6dd4b5. * test(gateway): fix uws server * test(gateway): fix type * chore: update codecov flag * test(gateway): remove dev code --------- Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> * Update release.yml (#2768) * fix: bot logger (#2769) * fix: readme runtime list * Fix code style issues with ESLint * node 18 * fix: websocket import type * fix: body for interaction requests * fix: perma fix for type error in ci * fix: followupmessage option type * fix: e2e tests exit bug * fix: color console logger * fix: image file sending * Fix code style issues with ESLint * guild and role methods * Fix code style issues with ESLint * fix: dont send heartbeat if socket is not open * fix: remove logs * fox: remove more logs * fix some bugs in role tests * Switch to after hook style * hoti's speed snaker * auto convert objects for discord * Fix code style issues with ESLint * fix: remove dup imports * fix: i hate linters * speeder * fix: tests delete guilds * Fix code style issues with ESLint * fix: easier to provide custom intents in bot * fix: shutdown bot after test * fix: add getGuild * fix: multiple guild delete attempts * fix: add emoji e2e tests * fix: remaining old e2e rest tests * Fix code style issues with ESLint * fix: add bot.logger * fix: make logger name capital --------- Co-authored-by: Lint Action <lint-action@samuelmeuli.com> * chore: update readme (#2772) * chore: add coverage per pkg * chore: add npm version * chore: add test status * chore: fix ci * chore: fix ci * ci: fix ci needs * chore: add only push event * style: remove import logger * 📚 - docs: fix README package links (#2773) * test(all): add test importing index (#2774) * test(all): add test importing index * chore: remove old benchmark dir * chore: disable coverage status fail * test(client): add import test with try catch * test(rest): fix narrow import scope * test(utils): add test (#2764) * test(utils): remove old test * test(utils): add color test * test(utils): fix import mocha * test(utils): fix test type error * test(utils): remove dev code * fix(utils): bucket not export all function * test(utils): add some test for bucket * fix(utils): close #2775 * test(utils): add test for permissions.ts * test(utils): fix missing mocha import * fix(utils): better fix for #2775 * feat: addReaction & addReactions * feat: connectToVoice * fix: linters issues * fix: remove aliases and add createGuildFromTemplate * feat: deleteMessages * fix: reaction related helpers * mfa level * voie states editing * image urls * fix: typos * get message typeguards * fix: more helpers * fix: remaining helpers * fix: add logs to gateway manager * fix: rest resolve sends status and body * fix: lots of errors * fix: client errors * fix: remove old pkg * snaker * fix: broken util import for image url * fix: cleanup shard and circular deps * fix: remove ThreadChannel from GuildChannel * fix: generate interaction usage * fix: more bugs * fix: use node:events to import * fix(rest): add interface RestRequestRejection (#2782) * fix: remove invalid todo * fix: timeout bug --------- Co-authored-by: Skillz <skillz@discord.gg/ddeno> Co-authored-by: Jonathan Ho <heiheiho000@gmail.com> Co-authored-by: deepsarda <92147339+deepsarda@users.noreply.github.com> Co-authored-by: Awesome Stickz <awesome@stickz.dev> Co-authored-by: Lint Action <lint-action@samuelmeuli.com> Co-authored-by: Lars_und_so <46791248+Larsundso@users.noreply.github.com> Co-authored-by: ITOH <to@itoh.at> Co-authored-by: Yaikava <83710104+Yaikava@users.noreply.github.com> Co-authored-by: Andreas Fink <mail@afink.dev> --------- Co-authored-by: Jonathan Ho <48591478+H01001000@users.noreply.github.com> Co-authored-by: H01001000 <heiheiho000@gmail.com> Co-authored-by: deepsarda <92147339+deepsarda@users.noreply.github.com> Co-authored-by: Yaikava <83710104+Yaikava@users.noreply.github.com> Co-authored-by: Skillz <skillz@discord.gg/ddeno> Co-authored-by: Awesome Stickz <awesome@stickz.dev> Co-authored-by: Lint Action <lint-action@samuelmeuli.com> Co-authored-by: Lars_und_so <46791248+Larsundso@users.noreply.github.com> Co-authored-by: ITOH <to@itoh.at> Co-authored-by: Andreas Fink <mail@afink.dev>
This commit is contained in:
co-authored by
H01001000
Lint Action
Skillz
deepsarda
Awesome Stickz
Lars_und_so
ITOH
Yaikava
Andreas Fink
Jonathan Ho
parent
1a717ddc7d
commit
2714e1e7d1
+10
-15
@@ -1,19 +1,14 @@
|
|||||||
FROM mcr.microsoft.com/vscode/devcontainers/base:0-buster
|
# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18, 16, 14, 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster
|
||||||
|
ARG VARIANT=18-bullseye
|
||||||
ENV DENO_INSTALL=/deno
|
FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-${VARIANT}
|
||||||
RUN mkdir -p /deno \
|
|
||||||
&& curl -fsSL https://deno.land/x/install/install.sh | sh \
|
|
||||||
&& chown -R vscode /deno
|
|
||||||
|
|
||||||
ENV PATH=${DENO_INSTALL}/bin:${PATH} \
|
|
||||||
DENO_DIR=${DENO_INSTALL}/.cache/deno
|
|
||||||
|
|
||||||
# [Optional] Uncomment this section to install additional OS packages.
|
# [Optional] Uncomment this section to install additional OS packages.
|
||||||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||||
&& apt-get -y install --no-install-recommends make
|
# && apt-get -y install --no-install-recommends <your-package-list-here>
|
||||||
|
|
||||||
# Install node
|
# [Optional] Uncomment if you want to install an additional version of node using nvm
|
||||||
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash
|
# ARG EXTRA_NODE_VERSION=10
|
||||||
RUN apt-get -y install --no-install-recommends nodejs
|
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
|
||||||
|
|
||||||
USER vscode
|
# [Optional] Uncomment if you want to install more global node packages
|
||||||
|
# RUN su node -c "npm install -g <your-package-list -here>"
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18, 16, 14, 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster
|
||||||
|
ARG VARIANT=18-bullseye
|
||||||
|
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}
|
||||||
|
|
||||||
|
# Install tslint, typescript. eslint is installed by javascript image
|
||||||
|
ARG NODE_MODULES="tslint-to-eslint-config typescript"
|
||||||
|
COPY library-scripts/meta.env /usr/local/etc/vscode-dev-containers
|
||||||
|
RUN su node -c "umask 0002 && npm install -g ${NODE_MODULES}" \
|
||||||
|
&& npm cache clean --force > /dev/null 2>&1
|
||||||
|
|
||||||
|
# [Optional] Uncomment this section to install additional OS packages.
|
||||||
|
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||||
|
# && apt-get -y install --no-install-recommends <your-package-list-here>
|
||||||
|
|
||||||
|
# [Optional] Uncomment if you want to install an additional version of node using nvm
|
||||||
|
# ARG EXTRA_NODE_VERSION=10
|
||||||
|
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
|
||||||
@@ -1,50 +1,36 @@
|
|||||||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
|
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
|
||||||
// https://github.com/microsoft/vscode-dev-containers/tree/v0.162.0/containers/deno
|
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.0/containers/typescript-node
|
||||||
{
|
{
|
||||||
"name": "Deno",
|
"name": "Node.js & TypeScript",
|
||||||
"dockerFile": "Dockerfile",
|
"build": {
|
||||||
// Set *default* container specific settings.json values on container create.
|
"dockerfile": "Dockerfile",
|
||||||
"settings": {
|
// Update 'VARIANT' to pick a Node version: 18, 16, 14.
|
||||||
"terminal.integrated.defaultProfile.linux": "/bin/bash",
|
// Append -bullseye or -buster to pin to an OS version.
|
||||||
"deno.enable": true,
|
// Use -bullseye variants on local on arm64/Apple Silicon.
|
||||||
"editor.defaultFormatter": "denoland.vscode-deno",
|
"args": {
|
||||||
"editor.minimap.enabled": false,
|
"VARIANT": "18-bullseye"
|
||||||
"editor.wordWrap": "on",
|
}
|
||||||
"editor.codeActionsOnSave": {
|
},
|
||||||
"source.organizeImports": true,
|
|
||||||
"source.fixAll": true
|
// Configure tool-specific properties.
|
||||||
},
|
"customizations": {
|
||||||
"editor.fontSize": 16,
|
// Configure properties specific to VS Code.
|
||||||
"workbench.colorTheme": "Material Theme Darker",
|
"vscode": {
|
||||||
"workbench.iconTheme": "eq-material-theme-icons-darker",
|
// Add the IDs of extensions you want installed when the container is created.
|
||||||
"breadcrumbs.enabled": true,
|
"extensions": [
|
||||||
"editor.renderWhitespace": "all",
|
"dbaeumer.vscode-eslint",
|
||||||
"editor.suggestSelection": "first",
|
"esbenp.prettier-vscode",
|
||||||
"editor.formatOnSave": true,
|
"TabNine.tabnine-vscode"
|
||||||
"files.autoSave": "afterDelay",
|
]
|
||||||
"editor.fontFamily": "Fira Code, Menlo, Monaco, 'Courier New', monospace",
|
}
|
||||||
"typescript.updateImportsOnFileMove.enabled": "always",
|
},
|
||||||
"javascript.updateImportsOnFileMove.enabled": "always",
|
|
||||||
"deno.inlayHints.enumMemberValues.enabled": true,
|
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||||
"deno.inlayHints.functionLikeReturnTypes.enabled": true,
|
// "forwardPorts": [],
|
||||||
"deno.inlayHints.parameterNames.enabled": "all",
|
|
||||||
"deno.inlayHints.parameterNames.suppressWhenArgumentMatchesName": false,
|
// Use 'postCreateCommand' to run commands after the container is created.
|
||||||
"deno.inlayHints.parameterTypes.enabled": true,
|
// "postCreateCommand": "yarn install",
|
||||||
"deno.inlayHints.propertyDeclarationTypes.enabled": true,
|
|
||||||
"deno.inlayHints.variableTypes.enabled": true,
|
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
|
||||||
"deno.inlayHints.variableTypes.suppressWhenTypeMatchesName": false
|
"remoteUser": "node",
|
||||||
},
|
|
||||||
// Add the IDs of extensions you want installed when the container is created.
|
|
||||||
"extensions": [
|
|
||||||
"denoland.vscode-deno",
|
|
||||||
"pkief.material-icon-theme",
|
|
||||||
"equinusocio.vsc-material-theme",
|
|
||||||
"tabnine.tabnine-vscode"
|
|
||||||
],
|
|
||||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
|
||||||
// "forwardPorts": [],
|
|
||||||
// Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker.
|
|
||||||
// "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],
|
|
||||||
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
|
|
||||||
"remoteUser": "vscode"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"root": true,
|
||||||
|
// This tells ESLint to load the config from the package `eslint-config-custom`
|
||||||
|
"extends": [
|
||||||
|
"discordeno"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
deno: ["v1.x"]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: denoland/setup-deno@main
|
||||||
|
with:
|
||||||
|
deno-version: ${{ matrix.deno }}
|
||||||
|
- name: Get last tag version
|
||||||
|
run: |
|
||||||
|
echo "DISCORDENO_VERSION_OLD=$(wget -O- -q https://deno.land/x/discordeno/util/constants.ts | grep 'export const DISCORDENO_VERSION' | awk -F'= ' '{print $2}' | tr -d '"|;')" >> $GITHUB_ENV
|
||||||
|
- name: Get new tag version
|
||||||
|
run: echo "DISCORDENO_VERSION=$(cat util/constants.ts | grep 'export const DISCORDENO_VERSION' | awk -F'= ' '{print $2}' | tr -d '"|;')" >> $GITHUB_ENV
|
||||||
|
- name: Create tag
|
||||||
|
if: ${{ env.DISCORDENO_VERSION != env.DISCORDENO_VERSION_OLD }}
|
||||||
|
run: git tag ${{ env.DISCORDENO_VERSION }} && git push --tags
|
||||||
|
- uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: "16.x"
|
||||||
|
registry-url: "https://registry.npmjs.org"
|
||||||
|
- name: build npm
|
||||||
|
run: deno run -A ./dnt.ts ${{ env.DISCORDENO_VERSION }}
|
||||||
|
- name: npm publish
|
||||||
|
if: ${{ env.DISCORDENO_VERSION != env.DISCORDENO_VERSION_OLD }}
|
||||||
|
env:
|
||||||
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
run: cd npm && npm publish
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
name: Test Docusaurus build
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- "site/**"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test-deploy:
|
||||||
|
name: Test deployment
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: 14.x
|
||||||
|
cache: npm
|
||||||
|
cache-dependency-path: site/package-lock.json
|
||||||
|
- name: Test build
|
||||||
|
working-directory: site
|
||||||
|
run: |
|
||||||
|
npm ci
|
||||||
|
npm run build
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
name: Bot Pkg Test Status
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
bot-pkg-test-status:
|
||||||
|
name: Bot Pkg Test Status
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
name: Client Pkg Test Status
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
client-pkg-test-status:
|
||||||
|
name: Client Pkg Test Status
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
name: Discordeno Pkg Test Status
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
discordeno-pkg-test-status:
|
||||||
|
name: Discordeno Pkg Test Status
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
name: E2E Test
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
package:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
e2e-test:
|
||||||
|
name: E2E Test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
concurrency: e2e-test
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 18
|
||||||
|
- name: Get yarn cache directory path
|
||||||
|
id: yarn-cache-dir-path
|
||||||
|
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||||
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-yarn-
|
||||||
|
- run: yarn install --immutable
|
||||||
|
- name: Turbo Cache
|
||||||
|
id: turbo-cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: .turbo
|
||||||
|
key: ${{ runner.os }}-turbo-test:e2e-${{ inputs.package }}-${{ github.sha }}
|
||||||
|
- name: Build dist cache
|
||||||
|
if: steps.turbo-cache.outputs.cache-hit != 'true'
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: .turbo
|
||||||
|
key: ${{ runner.os }}-turbo-build-${{ github.sha }}
|
||||||
|
- name: E2E Test
|
||||||
|
run: yarn test:e2e --cache-dir=".turbo" --filter=./packages/${{ inputs.package }}
|
||||||
|
timeout-minutes: 5
|
||||||
|
env:
|
||||||
|
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
|
||||||
|
E2E_TEST_GUILD_ID: ${{ secrets.UNIT_TEST_GUILD_ID }}
|
||||||
|
PROXY_REST_SECRET: ${{ secrets.PROXY_REST_SECRET }}
|
||||||
|
PROXY_REST_URL: ${{ secrets.PROXY_REST_URL }}
|
||||||
|
- name: Collect and upload the coverage report
|
||||||
|
uses: codecov/codecov-action@v3
|
||||||
|
with:
|
||||||
|
files: ./packages/${{ inputs.package }}/coverage/lcov.info
|
||||||
|
flags: ${{ inputs.package }}-e2e,${{ inputs.package }}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
name: Gateway Pkg Test Status
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
gateway-pkg-test-status:
|
||||||
|
name: Gateway Pkg Test Status
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
name: Package Test
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
package:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
integration-test:
|
||||||
|
name: Integration Test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 18
|
||||||
|
- name: Get yarn cache directory path
|
||||||
|
id: yarn-cache-dir-path
|
||||||
|
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||||
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-yarn-
|
||||||
|
- run: yarn install --immutable
|
||||||
|
- name: Turbo Cache
|
||||||
|
id: turbo-cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: .turbo
|
||||||
|
key: ${{ runner.os }}-turbo-test:integration-${{ inputs.package }}-${{ github.sha }}
|
||||||
|
- name: Build dist cache
|
||||||
|
if: steps.turbo-cache.outputs.cache-hit != 'true'
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: .turbo
|
||||||
|
key: ${{ runner.os }}-turbo-build-${{ github.sha }}
|
||||||
|
- name: Integration Test
|
||||||
|
run: yarn test:integration --cache-dir=".turbo" --filter=./packages/${{ inputs.package }}
|
||||||
|
timeout-minutes: 1
|
||||||
|
- name: Collect and upload the coverage report
|
||||||
|
uses: codecov/codecov-action@v3
|
||||||
|
with:
|
||||||
|
files: ./packages/${{ inputs.package }}/coverage/lcov.info
|
||||||
|
flags: ${{ inputs.package }}-integration,${{ inputs.package }}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
name: Lint
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
run-linters:
|
||||||
|
name: Run linters
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Check out Git repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 18
|
||||||
|
- name: Get yarn cache directory path
|
||||||
|
id: yarn-cache-dir-path
|
||||||
|
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||||
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-yarn-
|
||||||
|
- run: yarn install --immutable
|
||||||
|
- name: Run linters
|
||||||
|
uses: wearerequired/lint-action@v2
|
||||||
|
with:
|
||||||
|
auto_fix: true
|
||||||
|
eslint: true
|
||||||
|
eslint_extensions: "js,ts"
|
||||||
|
prettier: true
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
name: Other Runtime Package Test
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
package:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deno-unit-test:
|
||||||
|
name: Deno Unit Test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 18
|
||||||
|
- uses: denoland/setup-deno@main
|
||||||
|
with:
|
||||||
|
deno-version: "v1.29"
|
||||||
|
- name: Get yarn cache directory path
|
||||||
|
id: yarn-cache-dir-path
|
||||||
|
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||||
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-yarn-
|
||||||
|
- run: yarn install --immutable
|
||||||
|
- name: Turbo Cache
|
||||||
|
id: turbo-cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: .turbo
|
||||||
|
key: ${{ runner.os }}-turbo-test:deno-unit-${{ inputs.package }}-${{ github.sha }}
|
||||||
|
- name: Build dist cache
|
||||||
|
if: steps.turbo-cache.outputs.cache-hit != 'true'
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: .turbo
|
||||||
|
key: ${{ runner.os }}-turbo-build-${{ github.sha }}
|
||||||
|
- name: Deno Unit Test
|
||||||
|
run: yarn test:deno-unit --cache-dir=".turbo" --filter=./packages/${{ inputs.package }}
|
||||||
@@ -4,35 +4,97 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
<<<<<<< HEAD
|
||||||
|
- node-migration-clean
|
||||||
|
paths:
|
||||||
|
- packages/**
|
||||||
|
- .github/**
|
||||||
|
=======
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
>>>>>>> 1a717ddc7d97e31d3775747df9df153729d2925d
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
path-filter:
|
||||||
|
name: Check Path Changes
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
bot: ${ steps.changes.outputs.bot }
|
||||||
|
gateway: ${ steps.changes.outputs.gateway }
|
||||||
|
rest: ${ steps.changes.outputs.rest }
|
||||||
|
types: ${ steps.changes.outputs.types }
|
||||||
|
utils: ${ steps.changes.outputs.utils }
|
||||||
|
global: ${ steps.changes.outputs.global }
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: dorny/paths-filter@v2
|
||||||
|
id: changes
|
||||||
|
with:
|
||||||
|
base: node-migration-clean
|
||||||
|
filters: |
|
||||||
|
gateway:
|
||||||
|
- "packages/gateway/**"
|
||||||
|
rest:
|
||||||
|
- "packages/rest/**"
|
||||||
|
types:
|
||||||
|
- "packages/types/**"
|
||||||
|
utils:
|
||||||
|
- "packages/utils/**"
|
||||||
|
bot:
|
||||||
|
- "packages/bot/**"
|
||||||
|
global:
|
||||||
|
- ".github/**"
|
||||||
|
|
||||||
publish:
|
publish:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
strategy:
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
deno: ["v1.x"]
|
package: ["gateway", "rest", "types", "utils", "bot"]
|
||||||
|
run: ["false"]
|
||||||
|
exclude:
|
||||||
|
- package: gateway
|
||||||
|
run: "${{ needs.path-filter.outputs.gateway == 'true' || needs.path-filter.outputs.global == 'true' }}"
|
||||||
|
- package: rest
|
||||||
|
run: "${{ needs.path-filter.outputs.rest == 'true' || needs.path-filter.outputs.global == 'true' }}"
|
||||||
|
- package: types
|
||||||
|
run: "${{ needs.path-filter.outputs.types == 'true' || needs.path-filter.outputs.global == 'true' }}"
|
||||||
|
- package: utils
|
||||||
|
run: "${{ needs.path-filter.outputs.utils == 'true' || needs.path-filter.outputs.global == 'true' }}"
|
||||||
|
- package: bot
|
||||||
|
run: "${{ needs.path-filter.outputs.bot == 'true' || needs.path-filter.outputs.global == 'true' }}"
|
||||||
|
needs: path-filter
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: denoland/setup-deno@main
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
deno-version: ${{ matrix.deno }}
|
node-version: 18
|
||||||
- name: Get last tag version
|
registry-url: "https://registry.npmjs.org"
|
||||||
run: |
|
scope: "@discordeno"
|
||||||
echo "DISCORDENO_VERSION_OLD=$(wget -O- -q https://deno.land/x/discordeno/util/constants.ts | grep 'export const DISCORDENO_VERSION' | awk -F'= ' '{print $2}' | tr -d '"|;')" >> $GITHUB_ENV
|
- name: Get yarn cache directory path
|
||||||
- name: Get new tag version
|
id: yarn-cache-dir-path
|
||||||
run: echo "DISCORDENO_VERSION=$(cat util/constants.ts | grep 'export const DISCORDENO_VERSION' | awk -F'= ' '{print $2}' | tr -d '"|;')" >> $GITHUB_ENV
|
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
||||||
- name: Create tag
|
- uses: actions/cache@v3
|
||||||
if: ${{ env.DISCORDENO_VERSION != env.DISCORDENO_VERSION_OLD }}
|
|
||||||
run: git tag ${{ env.DISCORDENO_VERSION }} && git push --tags
|
|
||||||
- uses: actions/setup-node@v2
|
|
||||||
with:
|
with:
|
||||||
node-version: '16.x'
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||||
registry-url: 'https://registry.npmjs.org'
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||||
- name: build npm
|
restore-keys: |
|
||||||
run: deno run -A ./dnt.ts ${{ env.DISCORDENO_VERSION }}
|
${{ runner.os }}-yarn-
|
||||||
- name: npm publish
|
- run: yarn install --immutable
|
||||||
if: ${{ env.DISCORDENO_VERSION != env.DISCORDENO_VERSION_OLD }}
|
- name: Turbo Cache
|
||||||
|
id: turbo-cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: .turbo
|
||||||
|
key: ${{ runner.os }}-turbo-release-build-${{ matrix.package }}-${{ github.sha }}
|
||||||
|
- name: build Package
|
||||||
|
run: yarn release-build --cache-dir=".turbo" --filter=./packages/${{ matrix.package }}
|
||||||
|
- name: Bump Package Version
|
||||||
|
run: node ./scripts/bumpVersionByCommit.js ${{ matrix.package }}
|
||||||
|
|
||||||
|
- run: npm publish --access public
|
||||||
|
working-directory: packages/${{ matrix.package }}
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
run: cd npm && npm publish
|
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
name: Rest Pkg Test Status
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
rest-pkg-test-status:
|
||||||
|
name: Rest Pkg Test Status
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
+229
-94
@@ -5,109 +5,244 @@ on:
|
|||||||
push:
|
push:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
format-test:
|
build-type-and-test:
|
||||||
|
name: Build Type and Test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 18
|
||||||
|
- name: Get yarn cache directory path
|
||||||
|
id: yarn-cache-dir-path
|
||||||
|
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||||
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-yarn-
|
||||||
|
- run: yarn install --immutable
|
||||||
|
- name: Turbo Cache
|
||||||
|
id: turbo-cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: .turbo
|
||||||
|
key: ${{ runner.os }}-turbo-build:type-${{ github.sha }}
|
||||||
|
- name: Build Type and Test
|
||||||
|
run: yarn build:type --cache-dir=".turbo"
|
||||||
|
|
||||||
|
build-dist:
|
||||||
|
name: Build Dist
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 18
|
||||||
|
- name: Get yarn cache directory path
|
||||||
|
id: yarn-cache-dir-path
|
||||||
|
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||||
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-yarn-
|
||||||
|
- run: yarn install --immutable
|
||||||
|
- name: Turbo Cache
|
||||||
|
id: turbo-cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: .turbo
|
||||||
|
key: ${{ runner.os }}-turbo-build-${{ github.sha }}
|
||||||
|
- name: Type Test
|
||||||
|
run: yarn build --cache-dir=".turbo"
|
||||||
|
|
||||||
|
format-unit-and-integration-test:
|
||||||
name: Format Test
|
name: Format Test
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
needs: build-type-and-test
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: denoland/setup-deno@main
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
deno-version: v1.x
|
node-version: 18
|
||||||
|
- name: Get yarn cache directory path
|
||||||
|
id: yarn-cache-dir-path
|
||||||
|
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||||
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-yarn-
|
||||||
|
- run: yarn install --immutable
|
||||||
|
- name: Turbo Cache
|
||||||
|
id: turbo-cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: .turbo
|
||||||
|
key: ${{ runner.os }}-turbo-lint-${{ github.sha }}
|
||||||
|
- name: Build type cache
|
||||||
|
if: steps.turbo-cache.outputs.cache-hit != 'true'
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: .turbo
|
||||||
|
key: ${{ runner.os }}-turbo-build:type-${{ github.sha }}
|
||||||
- name: Check Formatting
|
- name: Check Formatting
|
||||||
run: deno fmt --check
|
run: yarn lint --cache-dir=".turbo"
|
||||||
|
|
||||||
# change if any prod code changed, skip test without change
|
test-type-unit-and-integration-test:
|
||||||
path-filter:
|
name: Test Type Test
|
||||||
name: Check Path Changes
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
needs: build-type-and-test
|
||||||
code-change: ${{ steps.changes.outputs.code-change }}
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: dorny/paths-filter@v2
|
- uses: actions/setup-node@v3
|
||||||
id: changes
|
|
||||||
with:
|
with:
|
||||||
filters: |
|
node-version: 18
|
||||||
code-change:
|
- name: Get yarn cache directory path
|
||||||
- ".github/workflows/test.yml"
|
id: yarn-cache-dir-path
|
||||||
- "gateway/**"
|
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
||||||
- "handlers/**"
|
- uses: actions/cache@v3
|
||||||
- "helpers/**"
|
with:
|
||||||
- "packages/**"
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||||
- "plugins/**"
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||||
- "rest/**"
|
restore-keys: |
|
||||||
- "template/**"
|
${{ runner.os }}-yarn-
|
||||||
- "tests/**"
|
- run: yarn install --immutable
|
||||||
- "transformers/**"
|
- name: Turbo Cache
|
||||||
- "types/**"
|
id: turbo-cache
|
||||||
- "util/**"
|
uses: actions/cache@v3
|
||||||
- "bot.ts"
|
with:
|
||||||
- "mod.ts"
|
path: .turbo
|
||||||
- "dnt.ts"
|
key: ${{ runner.os }}-turbo-unit-and-integration-test:test-type-${{ github.sha }}
|
||||||
|
- name: Build type cache
|
||||||
|
if: steps.turbo-cache.outputs.cache-hit != 'true'
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: .turbo
|
||||||
|
key: ${{ runner.os }}-turbo-build:type-${{ github.sha }}
|
||||||
|
- name: Test Type Test
|
||||||
|
run: yarn test:test-type --cache-dir=".turbo"
|
||||||
|
|
||||||
type-test:
|
# Not using matrix because test later on cant needs a specific job
|
||||||
name: Type Test
|
client-unit-test:
|
||||||
runs-on: ubuntu-latest
|
name: Client
|
||||||
needs: path-filter
|
needs: build-dist
|
||||||
if: ${{ needs.path-filter.outputs.code-change == 'true' }}
|
uses: ./.github/workflows/unit-test.yml
|
||||||
steps:
|
with:
|
||||||
- uses: actions/checkout@v3
|
package: client
|
||||||
- uses: denoland/setup-deno@main
|
client-other-runtime-test:
|
||||||
with:
|
name: Client
|
||||||
deno-version: v1.x
|
needs: client-unit-test
|
||||||
- name: Check dependencies
|
uses: ./.github/workflows/other-runtime-unit-test.yml
|
||||||
run: deno check mod.ts
|
with:
|
||||||
- name: Check plugins
|
package: client
|
||||||
run: deno check plugins/mod.ts
|
client-test-status:
|
||||||
- name: Check Templates
|
name: Client
|
||||||
run: deno check template/beginner/mod.ts template/minimal/mod.ts
|
needs: [client-other-runtime-test]
|
||||||
|
uses: ./.github/workflows/client-pkg-test-status.yml
|
||||||
integration-test:
|
discordeno-unit-test:
|
||||||
name: Integration Test
|
name: Discordeno
|
||||||
runs-on: ubuntu-latest
|
needs: build-dist
|
||||||
needs: path-filter
|
uses: ./.github/workflows/unit-test.yml
|
||||||
if: ${{ needs.path-filter.outputs.code-change == 'true' && github.ref == 'refs/heads/main' }}
|
with:
|
||||||
concurrency: integration-test
|
package: discordeno
|
||||||
steps:
|
discordeno-other-runtime-test:
|
||||||
- uses: actions/checkout@v3
|
name: Discordeno
|
||||||
- uses: denoland/setup-deno@main
|
needs: discordeno-unit-test
|
||||||
with:
|
uses: ./.github/workflows/other-runtime-unit-test.yml
|
||||||
deno-version: v1.x
|
with:
|
||||||
- name: Run integration
|
package: discordeno
|
||||||
# if: ${{ github.actor == 'Skillz4Killz' || github.actor == 'itohatweb' }}
|
discordeno-test-status:
|
||||||
run: deno test --coverage=coverage -A tests/
|
name: Discordeno
|
||||||
env:
|
needs: [discordeno-other-runtime-test]
|
||||||
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
|
uses: ./.github/workflows/discordeno-pkg-test-status.yml
|
||||||
UNIT_TEST_GUILD_ID: ${{ secrets.UNIT_TEST_GUILD_ID }}
|
gateway-unit-test:
|
||||||
TEST_ENV: INTEGRATION
|
name: Gateway
|
||||||
PROXY_REST_SECRET: ${{ secrets.PROXY_REST_SECRET }}
|
needs: build-dist
|
||||||
PROXY_REST_URL: ${{ secrets.PROXY_REST_URL }}
|
uses: ./.github/workflows/unit-test.yml
|
||||||
- name: Create coverage report
|
with:
|
||||||
run: deno coverage --exclude=tests ./coverage --lcov > coverage.lcov
|
package: gateway
|
||||||
- name: Collect and upload the coverage report
|
gateway-integration-test:
|
||||||
uses: codecov/codecov-action@v3
|
name: Gateway
|
||||||
with:
|
needs: build-dist
|
||||||
file: ./coverage.lcov
|
uses: ./.github/workflows/integration-test.yml
|
||||||
flags: integration
|
with:
|
||||||
|
package: gateway
|
||||||
unit-test:
|
gateway-other-runtime-test:
|
||||||
name: Unit Test
|
name: Gateway
|
||||||
runs-on: ubuntu-latest
|
needs: [gateway-unit-test, gateway-integration-test]
|
||||||
needs: path-filter
|
uses: ./.github/workflows/other-runtime-unit-test.yml
|
||||||
if: ${{ needs.path-filter.outputs.code-change == 'true' }}
|
with:
|
||||||
steps:
|
package: gateway
|
||||||
- uses: actions/checkout@v3
|
gateway-test-status:
|
||||||
- uses: denoland/setup-deno@main
|
name: Gateway
|
||||||
with:
|
needs: [gateway-other-runtime-test]
|
||||||
deno-version: v1.x
|
uses: ./.github/workflows/gateway-pkg-test-status.yml
|
||||||
- name: Run integration
|
rest-unit-test:
|
||||||
run: deno test --coverage=coverage --parallel -A tests/
|
name: Rest
|
||||||
env:
|
needs: build-dist
|
||||||
TEST_ENV: UNIT
|
uses: ./.github/workflows/unit-test.yml
|
||||||
- name: Create coverage report
|
with:
|
||||||
run: deno coverage --exclude=tests ./coverage --lcov > coverage.lcov
|
package: rest
|
||||||
- name: Collect and upload the coverage report
|
rest-e2e-test:
|
||||||
uses: codecov/codecov-action@v3
|
name: Rest
|
||||||
with:
|
needs: rest-unit-test
|
||||||
file: ./coverage.lcov
|
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/node-migration' || github.ref == 'refs/heads/node-migration-clean' }}
|
||||||
flags: unit
|
uses: ./.github/workflows/e2e-test.yml
|
||||||
|
secrets: inherit
|
||||||
|
with:
|
||||||
|
package: rest
|
||||||
|
rest-other-runtime-test:
|
||||||
|
name: Rest
|
||||||
|
needs: rest-unit-test
|
||||||
|
uses: ./.github/workflows/other-runtime-unit-test.yml
|
||||||
|
with:
|
||||||
|
package: rest
|
||||||
|
rest-test-status:
|
||||||
|
name: Rest
|
||||||
|
needs: [rest-e2e-test, rest-other-runtime-test]
|
||||||
|
uses: ./.github/workflows/rest-pkg-test-status.yml
|
||||||
|
utils-unit-test:
|
||||||
|
name: Utils
|
||||||
|
needs: build-dist
|
||||||
|
uses: ./.github/workflows/unit-test.yml
|
||||||
|
with:
|
||||||
|
package: utils
|
||||||
|
utils-other-runtime-test:
|
||||||
|
name: Utils
|
||||||
|
needs: utils-unit-test
|
||||||
|
uses: ./.github/workflows/other-runtime-unit-test.yml
|
||||||
|
with:
|
||||||
|
package: utils
|
||||||
|
utils-test-status:
|
||||||
|
name: Utils
|
||||||
|
needs: [utils-other-runtime-test]
|
||||||
|
uses: ./.github/workflows/utils-pkg-test-status.yml
|
||||||
|
bot-unit-test:
|
||||||
|
name: Bot
|
||||||
|
needs: build-dist
|
||||||
|
uses: ./.github/workflows/unit-test.yml
|
||||||
|
with:
|
||||||
|
package: bot
|
||||||
|
bot-e2e-test:
|
||||||
|
name: Bot
|
||||||
|
needs: bot-unit-test
|
||||||
|
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/node-migration' || github.ref == 'refs/heads/node-migration-clean' }}
|
||||||
|
uses: ./.github/workflows/e2e-test.yml
|
||||||
|
secrets: inherit
|
||||||
|
with:
|
||||||
|
package: bot
|
||||||
|
bot-other-runtime-test:
|
||||||
|
name: Bot
|
||||||
|
needs: bot-unit-test
|
||||||
|
uses: ./.github/workflows/other-runtime-unit-test.yml
|
||||||
|
with:
|
||||||
|
package: bot
|
||||||
|
bot-test-status:
|
||||||
|
name: Bot
|
||||||
|
needs: [bot-e2e-test, bot-other-runtime-test]
|
||||||
|
uses: ./.github/workflows/bot-pkg-test-status.yml
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
name: Types Pkg Test Status
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
types-pkg-test-status:
|
||||||
|
name: Types Pkg Test Status
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
name: Package Test
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
package:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
unit-test:
|
||||||
|
name: Unit Test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 18
|
||||||
|
- name: Get yarn cache directory path
|
||||||
|
id: yarn-cache-dir-path
|
||||||
|
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||||
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-yarn-
|
||||||
|
- run: yarn install --immutable
|
||||||
|
- name: Turbo Cache
|
||||||
|
id: turbo-cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: .turbo
|
||||||
|
key: ${{ runner.os }}-turbo-test:unit-${{ inputs.package }}-${{ github.sha }}
|
||||||
|
- name: Build dist cache
|
||||||
|
if: steps.turbo-cache.outputs.cache-hit != 'true'
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: .turbo
|
||||||
|
key: ${{ runner.os }}-turbo-build-${{ github.sha }}
|
||||||
|
- name: Unit Test
|
||||||
|
run: yarn test:unit --cache-dir=".turbo" --filter=./packages/${{ inputs.package }}
|
||||||
|
timeout-minutes: 1
|
||||||
|
- name: Collect and upload the coverage report
|
||||||
|
uses: codecov/codecov-action@v3
|
||||||
|
with:
|
||||||
|
files: ./packages/${{ inputs.package }}/coverage/lcov.info
|
||||||
|
flags: ${{ inputs.package }}-unit,${{ inputs.package }}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
name: Utils Pkg Test Status
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
utils-pkg-test-status:
|
||||||
|
name: Utils Pkg Test Status
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
+45
-12
@@ -1,17 +1,50 @@
|
|||||||
# Allows quick testing of changes and keeps stuff like tokens private
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||||
|
|
||||||
|
# Test file for testing dd changes
|
||||||
debug.ts
|
debug.ts
|
||||||
./configs.ts
|
|
||||||
.env
|
|
||||||
|
|
||||||
# npm stuff
|
# dependencies
|
||||||
.npmignore
|
node_modules
|
||||||
npm/
|
|
||||||
|
|
||||||
# MacOS is weird
|
.pnp.*
|
||||||
|
.yarn/*
|
||||||
|
!.yarn/patches
|
||||||
|
!.yarn/plugins
|
||||||
|
!.yarn/releases
|
||||||
|
!.yarn/sdks
|
||||||
|
!.yarn/versions
|
||||||
|
apps/site/docs/generated/classes
|
||||||
|
apps/site/docs/generated/enums
|
||||||
|
apps/site/docs/generated/interfaces
|
||||||
|
apps/site/docs/generated/modules
|
||||||
|
# testing
|
||||||
|
coverage
|
||||||
|
|
||||||
|
# build
|
||||||
|
dist
|
||||||
|
denoTestsDist
|
||||||
|
benchDist
|
||||||
|
out
|
||||||
|
build
|
||||||
|
.docusaurus
|
||||||
|
.cache-loader
|
||||||
|
|
||||||
|
# misc
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
*.pem
|
||||||
|
|
||||||
# benchmark db and output
|
# debug
|
||||||
db
|
npm-debug.log*
|
||||||
db.tar.gz
|
yarn-debug.log*
|
||||||
output.txt
|
yarn-error.log*
|
||||||
benchmarksResult
|
.pnpm-debug.log*
|
||||||
|
|
||||||
|
# local env files
|
||||||
|
.env
|
||||||
|
.env.local
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
|
||||||
|
# turbo
|
||||||
|
.turbo
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
. "$(dirname -- "$0")/_/husky.sh"
|
||||||
|
|
||||||
|
npx lint-staged
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
# ignore everything
|
||||||
|
*
|
||||||
|
|
||||||
|
# except package.json and build
|
||||||
|
!package.json
|
||||||
|
!README.md
|
||||||
|
!dist/*
|
||||||
|
|
||||||
|
# but not tsc cache
|
||||||
|
dist/tsconfig.tsbuildinfo
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"trailingComma": "all",
|
||||||
|
"useTabs": false,
|
||||||
|
"singleQuote": true,
|
||||||
|
"semi": false,
|
||||||
|
"printWidth": 150
|
||||||
|
}
|
||||||
Vendored
+6
-34
@@ -1,40 +1,12 @@
|
|||||||
{
|
{
|
||||||
"deno.enable": true,
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||||
"deno.lint": false,
|
|
||||||
"deno.unstable": true,
|
|
||||||
"deno.enablePaths": [
|
|
||||||
"./benchmarks",
|
|
||||||
"./gateway",
|
|
||||||
"./handlers",
|
|
||||||
"./helpers",
|
|
||||||
"./plugins",
|
|
||||||
"./packages",
|
|
||||||
"./performance",
|
|
||||||
"./rest",
|
|
||||||
"./template/beginner",
|
|
||||||
"./template/minimal",
|
|
||||||
"./tests",
|
|
||||||
"./transformers",
|
|
||||||
"./types",
|
|
||||||
"./util",
|
|
||||||
"dnt.ts",
|
|
||||||
"mod.ts",
|
|
||||||
"debug.ts",
|
|
||||||
"debug.rest.ts",
|
|
||||||
"bot.ts"
|
|
||||||
],
|
|
||||||
"editor.defaultFormatter": "denoland.vscode-deno",
|
|
||||||
"editor.formatOnSave": true,
|
"editor.formatOnSave": true,
|
||||||
"editor.codeActionsOnSave": {
|
"editor.codeActionsOnSave": {
|
||||||
"source.organizeImports": true,
|
"source.organizeImports": true,
|
||||||
"source.fixAll": true
|
"source.fixAll": true
|
||||||
},
|
},
|
||||||
"deno.inlayHints.enumMemberValues.enabled": true,
|
"[typescript]": {
|
||||||
"deno.inlayHints.functionLikeReturnTypes.enabled": true,
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
"deno.inlayHints.parameterNames.enabled": "all",
|
},
|
||||||
"deno.inlayHints.parameterNames.suppressWhenArgumentMatchesName": false,
|
"typescript.tsdk": "node_modules\\typescript\\lib"
|
||||||
"deno.inlayHints.parameterTypes.enabled": true,
|
}
|
||||||
"deno.inlayHints.propertyDeclarationTypes.enabled": true,
|
|
||||||
"deno.inlayHints.variableTypes.enabled": true,
|
|
||||||
"deno.inlayHints.variableTypes.suppressWhenTypeMatchesName": false
|
|
||||||
}
|
|
||||||
File diff suppressed because one or more lines are too long
Vendored
+807
File diff suppressed because one or more lines are too long
@@ -0,0 +1,7 @@
|
|||||||
|
nodeLinker: node-modules
|
||||||
|
|
||||||
|
plugins:
|
||||||
|
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
|
||||||
|
spec: "@yarnpkg/plugin-typescript"
|
||||||
|
|
||||||
|
yarnPath: .yarn/releases/yarn-3.3.0.cjs
|
||||||
@@ -2,13 +2,23 @@
|
|||||||
|
|
||||||
<img align="right" src="https://raw.githubusercontent.com/discordeno/discordeno/main/site/static/img/logo.png" height="150px">
|
<img align="right" src="https://raw.githubusercontent.com/discordeno/discordeno/main/site/static/img/logo.png" height="150px">
|
||||||
|
|
||||||
Discord API library for [Deno](https://deno.land)
|
Discord API library for Node.JS, [Deno](https://deno.land) & Bun
|
||||||
|
|
||||||
Discordeno follows [semantic versioning](https://semver.org/)
|
Discordeno follows [semantic versioning](https://semver.org/)
|
||||||
|
|
||||||
[](https://discord.com/invite/5vBgXk3UcZ)
|
[](https://discord.com/invite/5vBgXk3UcZ)
|
||||||

|

|
||||||
[](https://codecov.io/gh/discordeno/discordeno)
|
|
||||||
|
## Packages
|
||||||
|
|
||||||
|
| Package | npm | Tests | Coverage |
|
||||||
|
| ---------------------------------------------------------------------- | ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
| [discordeno](https://www.npmjs.com/package/discordeno) |  |  | [](https://codecov.io/gh/discordeno/discordeno) |
|
||||||
|
| [@discordeno/types](https://www.npmjs.com/package/@discordeno/types) |  |  | [](https://codecov.io/gh/discordeno/discordeno) |
|
||||||
|
| [@discordeno/utils](https://www.npmjs.com/package/@discordeno/utils) |  |  | [](https://codecov.io/gh/discordeno/discordeno) |
|
||||||
|
| [@discordeno/rest](https://www.npmjs.com/package/@discordeno/rest) |  |  | [](https://codecov.io/gh/discordeno/discordeno) |
|
||||||
|
| [@discordeno/gateway](https://www.npmjs.com/package/@discordeno/gateway) |  |  | [](https://codecov.io/gh/discordeno/discordeno) |
|
||||||
|
| [@discordeno/bot](https://www.npmjs.com/package/@discordeno/bot) |  |  | [](https://codecov.io/gh/discordeno/discordeno) |
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
@@ -24,6 +34,7 @@ Discordeno is actively maintained to guarantee **excellent performance and ease.
|
|||||||
- **Plugins:** Designed to allow you to overwrite any portion of the code with your own code. Never go through the
|
- **Plugins:** Designed to allow you to overwrite any portion of the code with your own code. Never go through the
|
||||||
hassle of maintaining your fork in order to acquire something that is specifically tailored to your requirements.
|
hassle of maintaining your fork in order to acquire something that is specifically tailored to your requirements.
|
||||||
Plugins may be used for nearly anything; for instance, we have a few authorised plugins.
|
Plugins may be used for nearly anything; for instance, we have a few authorised plugins.
|
||||||
|
|
||||||
- A caching plugin that makes anything cacheable.
|
- A caching plugin that makes anything cacheable.
|
||||||
- A plugin for sweepers that allows them to periodically clear the cache.
|
- A plugin for sweepers that allows them to periodically clear the cache.
|
||||||
- The permission plugin internally verifies any missing permissions before sending a call to the Discord API to
|
- The permission plugin internally verifies any missing permissions before sending a call to the Discord API to
|
||||||
@@ -63,7 +74,7 @@ Discordeno is actively maintained to guarantee **excellent performance and ease.
|
|||||||
that was spread across 200,000 servers, restarting it after making a simple modification would take 20 minutes.
|
that was spread across 200,000 servers, restarting it after making a simple modification would take 20 minutes.
|
||||||
- **Zero Downtime Resharding:**
|
- **Zero Downtime Resharding:**
|
||||||
- At various periods in time, Discord stops allowing your bot to be added to new servers. Consider 150 shards
|
- At various periods in time, Discord stops allowing your bot to be added to new servers. Consider 150 shards
|
||||||
operating on 150,000 servers, for instance. Your shards may support a maximum of 150 * 2500 = 375,000 servers. Your
|
operating on 150,000 servers, for instance. Your shards may 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.
|
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.
|
- 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
|
- Automated: This system will automatically begin a Zero-downtime resharding process behind the scenes when you
|
||||||
@@ -102,24 +113,24 @@ Have your cache setup in any way you like. Redis, PGSQL or any cache layer you w
|
|||||||
Here is a minimal example to get started with:
|
Here is a minimal example to get started with:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { createBot, Intents, startBot } from "https://deno.land/x/discordeno@13.0.0/mod.ts";
|
import { createBot, Intents, startBot } from 'https://deno.land/x/discordeno@13.0.0/mod.ts'
|
||||||
|
|
||||||
const bot = createBot({
|
const bot = createBot({
|
||||||
token: Deno.env.get("DISCORD_TOKEN"),
|
token: process.env.DISCORD_TOKEN,
|
||||||
intents: Intents.Guilds | Intents.GuildMessages,
|
intents: Intents.Guilds | Intents.GuildMessages,
|
||||||
events: {
|
events: {
|
||||||
ready() {
|
ready() {
|
||||||
console.log("Successfully connected to gateway");
|
console.log('Successfully connected to gateway')
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
// Another way to do events
|
// Another way to do events
|
||||||
bot.events.messageCreate = function (b, message) {
|
bot.events.messageCreate = function (b, message) {
|
||||||
// Process the message here with your command handler.
|
// Process the message here with your command handler.
|
||||||
};
|
}
|
||||||
|
|
||||||
await startBot(bot);
|
await startBot(bot)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Tools
|
### Tools
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||||
|
|
||||||
|
# Test file for testing dd changes
|
||||||
|
debug.ts
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
node_modules
|
||||||
|
|
||||||
|
.pnp.*
|
||||||
|
.yarn/*
|
||||||
|
!.yarn/patches
|
||||||
|
!.yarn/plugins
|
||||||
|
!.yarn/releases
|
||||||
|
!.yarn/sdks
|
||||||
|
!.yarn/versions
|
||||||
|
|
||||||
|
# testing
|
||||||
|
coverage
|
||||||
|
|
||||||
|
# build
|
||||||
|
dist
|
||||||
|
out
|
||||||
|
build
|
||||||
|
.docusaurus
|
||||||
|
.cache-loader
|
||||||
|
|
||||||
|
# misc
|
||||||
|
.DS_Store
|
||||||
|
*.pem
|
||||||
|
|
||||||
|
# debug
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
.pnpm-debug.log*
|
||||||
|
|
||||||
|
# local env files
|
||||||
|
.env
|
||||||
|
.env.local
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
|
||||||
|
# turbo
|
||||||
|
.turbo
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
slug: welcome
|
||||||
|
title: Welcome
|
||||||
|
authors: [itoh, skillz]
|
||||||
|
tags: [discordeno, hello]
|
||||||
|
---
|
||||||
|
|
||||||
|
Hello and Welcome to Discordeno, a highly scalable Discord library for Deno and Node.js using TypeScript.
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
---
|
||||||
|
sidebar_position: 5
|
||||||
|
---
|
||||||
|
|
||||||
|
# Frequently Asked Questions
|
||||||
|
|
||||||
|
## Does Discordeno Support TypeScript?
|
||||||
|
|
||||||
|
TypeScript is supported to the highest standard by Discordeno. TypeScript is included in Discordeno since Deno supports it. This implies that before using TypeScript, you do not need to compile it. But this isn't the main reason Discordeno is the ideal library for TypeScript programmers. I was experimenting with a lot of various things when I created this library, and automatic typings was one of them.
|
||||||
|
|
||||||
|
When I utilised other libraries, I frequently observed incorrect or troublesome typings. This is so that TypeScript won't alert the library developers because most of the Discord API typings aren't utilised by the libraries themselves.
|
||||||
|
|
||||||
|
It is quite unlikely that these typings would become wrong or outdated as a result of minor errors like forgetting to update typings because Discordeno utilises them as part of the rest process. Libraries occasionally add a property without also adding it to their typings. Because of this, TypeScript developers cannot use it, only JavaScript developers can. Typings are crucial for TypeScript developers. Typings are treated as a component of the code by Discordeno! A breaking change in typings is a breaking change for the library!
|
||||||
|
|
||||||
|
## How Stable Is Discordeno?
|
||||||
|
|
||||||
|
Stability is one of the main problems with practically every library (I have used). None of the libraries showed TypeScript developers the love and care that they deserve. Because breaking changes to typings occasionally occurred without producing a MAJOR bump, TypeScript projects would occasionally fail. As a result, production TypeScript bots would fail. At times, I was the only one keeping the typings up to date for that library. Some libraries that were older than 1.0 didn't even have a stable branch or version, so I didn't have to worry about them undergoing breaking changes.
|
||||||
|
|
||||||
|
The finest stability for TypeScript developers is one of my basic goals for this library.
|
||||||
|
No matter how little, a change that impacts the public API qualifies as a breaking change. I don't care whether we reach version 500. As a library maintainer, you should never be scared to bump a MAJOR because it just involves a tiny modification or a type change because doing so will ruin the end user's experience.
|
||||||
|
|
||||||
|
## Why Doesn't Discordeno Use Classes or EventEmitter?
|
||||||
|
|
||||||
|
This is a design decision for the library itself. You can still use class on your bot if you want. In fact, I hope someone
|
||||||
|
makes a framework/templates for this lib one day using classes so that devs have a choice on which style they prefer.
|
||||||
|
Without trying to write an entire thesis statement on the reasons why I avoided Classes in this library, I will just link to
|
||||||
|
the best resources that I believe help explain it.
|
||||||
|
|
||||||
|
- [Really good article](https://dannyfritz.wordpress.com/2014/10/11/class-free-object-oriented-programming/)
|
||||||
|
- [Lecture by one of the developers who makes JavaScript](https://www.youtube.com/watch?v=PSGEjv3Tqo0)
|
||||||
|
|
||||||
|
In regards to EventEmitter, I believe a functional event API was a much better choice. EventEmitter at its core, is simply a set of functions that run when a certain event is emitted. In Discordeno, that function is executed instead of emitting some event to trigger it.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// EventEmitter Example
|
||||||
|
EventEmitter.emit("guildCreate", guild);
|
||||||
|
// Discordeno Example
|
||||||
|
bot.events.guildCreate?.(bot, guild);
|
||||||
|
```
|
||||||
|
|
||||||
|
There isn't really any difference especially for users when they use it. One bad thing about EventEmitter is that if
|
||||||
|
misused it can easily cause memory leaks. It is very easy to open yourself up to these memory leak issues. It has
|
||||||
|
happened to me when I started coding as well. This is why I wanted Discordeno's implementation to help devs avoid the
|
||||||
|
issues I had. It prevents anyone from having this as a potential issue. Another issue with EventEmitter is trying to
|
||||||
|
update the code in those functions without having to deal with headaches left and right of removing and adding
|
||||||
|
listeners. You don't need to worry about binding or not binding events. They are just pure functions
|
||||||
|
|
||||||
|
In Discordeno, this is extremely simple; you just simply give it the new event handlers. For example:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
bot.events.guildCreate = newGuildCreateEventHandler;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Why Do You Have A Class for Collection If Classes Are Bad?
|
||||||
|
|
||||||
|
The Collection class is an exception in the library where a class was allowed. This is because Collection extends Map.
|
||||||
|
The Map class is provided by JavaScript itself and is extremely fast. You can perform millions of operations a second
|
||||||
|
with a Map. Maps are too useful to avoid and don't have downsides like EventEmitters do. The Collection class simply
|
||||||
|
adds on other functionality that Discordeno users felt they needed. Although I am against using classes whenever
|
||||||
|
possible, I am also a big supporter of providing the best developer experience.
|
||||||
|
|
||||||
|
## Why Are there no options in Discordeno?
|
||||||
|
|
||||||
|
Discordeno is not a library that handles code in the exact way every person wants it to. It is opinionated. Discordeno
|
||||||
|
defaults to the Discord recommended options or the best options for majority of developers needs. For example, there is
|
||||||
|
no option of fetching all members startup. This is a practice that Discord does not recommend or want users doing. By
|
||||||
|
default, we don't support stuff like this. In Discordeno, we follow Discords recommended solution and it just works
|
||||||
|
internally. The End! No fuss! No Muss! Just good stuff!
|
||||||
|
|
||||||
|
Now, I understand that there are times when it's necessary to be able to customize this and fetch them all. If you are
|
||||||
|
advanced enough to need these options, you should be able to simply do it yourself. For most users, this is just an
|
||||||
|
unnecessary option. The main module should remain minimalistic and easy to use for 99% of users.
|
||||||
|
|
||||||
|
## Why Do I See errors Like "MISSING_VIEW_CHANNEL" or "BOTS_HIGHEST_ROLE_TOO_LOW"?
|
||||||
|
|
||||||
|
Discordeno is the only library(that I have used), that has built in permission handling. A lot of bots get automatically
|
||||||
|
banned by Discord because they forget to handle permissions. When bots don't check permissions and continue to send
|
||||||
|
requests to the API, this leads to bots being banned. I have tried to request adding this feature into libraries but
|
||||||
|
they were reluctant to do so because it would require the devs to maintain the library whenever an update was made by
|
||||||
|
Discord.
|
||||||
|
|
||||||
|
Discordeno provides you specific keywords that you can use to send a clean response to the end user of your choosing. I
|
||||||
|
have even seen some bots have hundreds of thousands of Missing Permission or Missing Access errors because libraries
|
||||||
|
don't handle it. IMO, this is a crucial part of any good library as much as it is to handle rate limiting.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { Bot, Errors, Message } from "https://deno.land/x/discordeno@16.0.0/mod.ts";
|
||||||
|
|
||||||
|
export function handleCommandError(bot: Bot, message: Message, type: Errors) {
|
||||||
|
switch (type) {
|
||||||
|
case Errors.MISSING_MANAGE_NICKNAMES:
|
||||||
|
return bot.helpers.sendMessage(message.channelId, {
|
||||||
|
content:
|
||||||
|
"The bot does not have the necessary permission to manage/edit other user's nicknames. Grant the **MANAGE_NICKNAME** permission to the bot and try again.",
|
||||||
|
});
|
||||||
|
case Errors.MISSING_MANAGE_ROLES:
|
||||||
|
// Note: i18n is not part of the library. This is just an example of how you could use i18n for custom error responses.
|
||||||
|
return bot.helpers.sendMessage(message.channelId, { content: i18n.translate(type) });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
|
||||||
@@ -0,0 +1,160 @@
|
|||||||
|
discordeno-monorepo / [Modules](modules.md)
|
||||||
|
|
||||||
|
# Discordeno
|
||||||
|
|
||||||
|
<img align="right" src="https://raw.githubusercontent.com/discordeno/discordeno/main/site/static/img/logo.png" height="150px">
|
||||||
|
|
||||||
|
Discord API library for [Deno](https://deno.land)
|
||||||
|
|
||||||
|
Discordeno follows [semantic versioning](https://semver.org/)
|
||||||
|
|
||||||
|
[](https://discord.com/invite/5vBgXk3UcZ)
|
||||||
|

|
||||||
|
[](https://codecov.io/gh/discordeno/discordeno)
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
Discordeno is actively maintained to guarantee **excellent performance and ease.**
|
||||||
|
|
||||||
|
- **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 and Deno 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.
|
||||||
|
- **Plugins:** Designed to allow you to overwrite any portion of the code with your own code. Never go through the
|
||||||
|
hassle of maintaining your fork in order to acquire something that is specifically tailored to your requirements.
|
||||||
|
Plugins may be used for nearly anything; for instance, we have a few authorised plugins.
|
||||||
|
|
||||||
|
- A caching plugin that makes anything cacheable.
|
||||||
|
- A plugin for sweepers that allows them to periodically clear the cache.
|
||||||
|
- The permission plugin internally verifies any missing permissions before sending a call to the Discord API to
|
||||||
|
prevent the client from receiving a Discord global ban.
|
||||||
|
|
||||||
|
- **Flexibility:** You may easily delete an object's attributes if your bot doesn't require them. For instance, you
|
||||||
|
shouldn't be required to keep `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
|
||||||
|
- By lowering the maximum downtime to 10 minutes, Discordeno will prevent your bot from being down for an hour.
|
||||||
|
- Freedom from global rate limit errors
|
||||||
|
- As your bot grows, you want to handle global rate limits better. Shards don't communicate fast enough to truly
|
||||||
|
handle it properly so this allows 1 rest handler across the entire bot.
|
||||||
|
- You may really run numerous instances of your bot on different hosts, all of which will 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! There's a chance you'll lose a lot of messages or replies that are waiting to be given when you
|
||||||
|
wish to update and restart the bot. You may restart your bot using this technique and never have to worry about
|
||||||
|
losing any answers.
|
||||||
|
- Single source of contact to Discord API
|
||||||
|
- As a result, you will be able to send requests to Discord from any location, even a bot dashboard. You are no longer
|
||||||
|
need to interact with your bot processes in order to submit a request or do anything else. Your bot process should
|
||||||
|
be freed up to handle bot events.
|
||||||
|
- Scalability! Scalability! Scalability!
|
||||||
|
|
||||||
|
### Gateway
|
||||||
|
|
||||||
|
- **Zero Downtime Updates:**
|
||||||
|
- A few seconds are needed to update your bot. When using conventional sharding, you must restart in addition to going
|
||||||
|
through a 1/5s rate-limited process of identifying all of your shards. As WS processing has been relocated to a
|
||||||
|
proxy process, you may resume the bot code right away without worrying about any delays. Normally, if you had a bot
|
||||||
|
that was spread across 200,000 servers, restarting it after making a simple modification would take 20 minutes.
|
||||||
|
- **Zero Downtime Resharding:**
|
||||||
|
- At various periods in time, Discord stops allowing your bot to be added to new servers. Consider 150 shards
|
||||||
|
operating on 150,000 servers, for instance. Your shards may 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.
|
||||||
|
- **Horizontal Scaling:**
|
||||||
|
- The bot may be scaled horizontally thanks to the proxy mechanism. When your business grows significantly, you have
|
||||||
|
two options: you can either keep investing money to upgrade your server or you may expand horizontally by purchasing
|
||||||
|
numerous more affordable servers. The proxy enables WS handling on a totally other system.
|
||||||
|
- **No Loss Restarts:**
|
||||||
|
- Without the proxy mechanism, you would typically lose numerous events while restarting a bot. Users could issue
|
||||||
|
instructions or send messages that are not screened. As your bot population increases, this amount grows sharply.
|
||||||
|
Users who don't receive the automatic roles or any other activities your bot should do may join. You may keep
|
||||||
|
restarting your bot thanks to the proxy technology without ever losing any events. While your bot is unavailable,
|
||||||
|
events will be added to a queue (the maximum size of the queue is configurable), and once the bot is back online,
|
||||||
|
the queue will start processing all of the events.
|
||||||
|
- **Controllers:**
|
||||||
|
- You have complete control over everything inside the proxy thanks to the controller aspect. To simply override the
|
||||||
|
handler, you may supply a function. For instance, you may simply give a method to override a specific function if
|
||||||
|
you want it to behave differently rather than forking and maintaining your fork.
|
||||||
|
- **Clustering With Workers:**
|
||||||
|
- Utilize all of your CPU cores to their greatest potential by distributing the workload across employees. To enhance
|
||||||
|
efficiency, manage how many employees and shards there are each worker!
|
||||||
|
|
||||||
|
### Custom Cache
|
||||||
|
|
||||||
|
Have your cache setup in any way you like. Redis, PGSQL or any cache layer you would like.
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
### Minimal Example
|
||||||
|
|
||||||
|
Here is a minimal example to get started with:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import {
|
||||||
|
createBot,
|
||||||
|
Intents,
|
||||||
|
startBot,
|
||||||
|
} from "https://deno.land/x/discordeno@13.0.0/mod.ts";
|
||||||
|
|
||||||
|
const bot = createBot({
|
||||||
|
token: process.env.DISCORD_TOKEN,
|
||||||
|
intents: Intents.Guilds | Intents.GuildMessages,
|
||||||
|
events: {
|
||||||
|
ready() {
|
||||||
|
console.log("Successfully connected to gateway");
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Another way to do events
|
||||||
|
bot.events.messageCreate = function (b, message) {
|
||||||
|
// Process the message here with your command handler.
|
||||||
|
};
|
||||||
|
|
||||||
|
await startBot(bot);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Tools
|
||||||
|
|
||||||
|
This library is not intended for beginners, however if you still want to utilise it, check out these excellent official
|
||||||
|
and unofficial templates:
|
||||||
|
|
||||||
|
**Templates**
|
||||||
|
|
||||||
|
- [Discordeno Template (official)](https://github.com/discordeno/discordeno/tree/main/template)
|
||||||
|
- [Serverless Slash Commands Template (official)](https://github.com/discordeno/serverless-deno-deploy-template)
|
||||||
|
- [`create-discordeno-bot` (WIP, unoffical)](https://github.com/Reboot-Codes/create-discordeno-bot/)
|
||||||
|
- [Add Your Own!](https://github.com/discordeno/discordeno/pulls)
|
||||||
|
|
||||||
|
**Frameworks**
|
||||||
|
|
||||||
|
- [Amethyst Framework](https://github.com/AmethystFramework/framework)
|
||||||
|
- [Add Your Own!](https://github.com/discordeno/discordeno/pulls)
|
||||||
|
|
||||||
|
**Plugins**
|
||||||
|
|
||||||
|
- [Cache Plugin](plugins/cache)
|
||||||
|
- [Fileloader Plugin](plugins/fileloader)
|
||||||
|
- [Helpers Plugin](plugins/helpers)
|
||||||
|
- [Permissions Plugin](plugins/permissions)
|
||||||
|
|
||||||
|
## Links
|
||||||
|
|
||||||
|
- [Website](https://discordeno.mod.land)
|
||||||
|
- [Documentation](https://doc.deno.land/https/deno.land/x/discordeno/mod.ts)
|
||||||
|
- [Discord](https://discord.com/invite/5vBgXk3UcZ)
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
[discordeno-monorepo](README.md) / Modules
|
||||||
|
|
||||||
|
# discordeno-monorepo
|
||||||
|
|
||||||
|
## Table of contents
|
||||||
|
|
||||||
|
### Modules
|
||||||
|
|
||||||
|
- [@discordeno/gateway](modules/discordeno_gateway.md)
|
||||||
|
- [@discordeno/logger](modules/discordeno_logger.md)
|
||||||
|
- [@discordeno/rest](modules/discordeno_rest.md)
|
||||||
|
- [@discordeno/types](modules/discordeno_types.md)
|
||||||
|
- [@discordeno/utils](modules/discordeno_utils.md)
|
||||||
|
- [@discordeno/client](modules/discordeno_client.md)
|
||||||
|
- [discordeno](modules/discordeno.md)
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
---
|
||||||
|
sidebar_position: 3
|
||||||
|
---
|
||||||
|
|
||||||
|
# Getting Started
|
||||||
|
|
||||||
|
Discordeno aims for a simple, easy and stress-free interaction with the Discord API. Always supporting the latest
|
||||||
|
version to ensure stability, consistency and the best developer experience. This guide serves as the purpose for
|
||||||
|
introducing Discordeno to developers.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- **Deno 1.0** or higher
|
||||||
|
|
||||||
|
## Creating your First Discord Bot Application
|
||||||
|
|
||||||
|
Plenty of guides are available on how to create a Discord Bot Application.
|
||||||
|
|
||||||
|
1. [Creating an Application](https://discord.com/developers/applications) on the Developer Portal, name something cool
|
||||||
|
and pick a sweet icon!
|
||||||
|
2. After creating an application. Save the **Client ID.** Thats the unique identifier for a Discord Bot.
|
||||||
|
3. Now, go and create a bot by clicking the **Bot** tab. You will see a **Token** section and thats the Discord Bot's
|
||||||
|
token. **Make sure you don't share that token with anyone!!!**
|
||||||
|
4. Invite the bot to the server, you can use the
|
||||||
|
**[Discord Permissions Calculator](https://discordapi.com/permissions.html#0)** for creating the invite link with
|
||||||
|
custom permissions. By default, `0` means no permissions and `8` means Administrator.
|
||||||
|
|
||||||
|
Now you've created an Application but it will need some code in order for it to be online. Thats when Discordeno comes
|
||||||
|
in handy!
|
||||||
|
|
||||||
|
> Make sure you store your tokens in a file that is NOT deployed by adding it to the .gitignore file. **Don't share your
|
||||||
|
> bot token with anybody.**
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
You can install Discordeno by importing:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { startBot } from "https://deno.land/x/discordeno@16.0.0/mod.ts";
|
||||||
|
```
|
||||||
|
|
||||||
|
## Example Usage
|
||||||
|
|
||||||
|
Starting with Discordeno is very simple, you can start from scratch without any templates/frameworks: Add this snippet
|
||||||
|
of code into a new TypeScript file:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { createBot, Intents, startBot } from "https://deno.land/x/discordeno/mod.ts";
|
||||||
|
|
||||||
|
startBot(
|
||||||
|
createBot({
|
||||||
|
token: "BOT TOKEN",
|
||||||
|
intents: Intents.Guilds | Intents.GuildMessages,
|
||||||
|
events: {
|
||||||
|
ready() {
|
||||||
|
console.log("Successfully connected to gateway");
|
||||||
|
},
|
||||||
|
messageCreate(bot, message) {
|
||||||
|
if (message.content === "!ping") {
|
||||||
|
bot.helpers.sendMessage(message.channelId, { content: "Pong using Discordeno!" });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Tutorials
|
||||||
|
|
||||||
|
Below you will find youtube playlists that display channels using Discordeno for their tutorials.
|
||||||
|
|
||||||
|
- [Making a Discord bot with Deno and Discordeno](https://web-mystery.com/articles/making-discord-bot-deno-and-discordeno)
|
||||||
|
- [Running a Discord bot written using Deno in Docker](https://web-mystery.com/articles/running-discord-bot-written-deno-docker)
|
||||||
|
- [Discordeno Bot Tutorials (YouTube)](https://youtu.be/rIph9-BGsuQ)
|
||||||
@@ -0,0 +1,469 @@
|
|||||||
|
---
|
||||||
|
sidebar_position: 4
|
||||||
|
---
|
||||||
|
|
||||||
|
# Migrating
|
||||||
|
|
||||||
|
## Migrating from Discord.js
|
||||||
|
|
||||||
|
This migration guide is not intended to discredit Discord.js authors/maintainers or Discord.js itself. In fact,
|
||||||
|
Discord.js is the most popular Node.js library, admired and praised by a lot of JavaScript developers.
|
||||||
|
|
||||||
|
## Finding an Open-Source Discord Bot
|
||||||
|
|
||||||
|
For the purposes of this guide, I wanted to find a moderation bot that is totally open source to show an example of how
|
||||||
|
to convert the bot to Discordeno. Trying to find one was not easy as most bot's were not using the latest Discord.JS
|
||||||
|
version 12. Trying to find one that was using TypeScript made it even more difficult. My next best solution was to find
|
||||||
|
a moderation bot that was recently updated(showing it is maintained or recently built). The best one I could find was
|
||||||
|
[Zodiac Bot](https://github.com/Nukestye/Zodiac).
|
||||||
|
|
||||||
|
For the purposes of this guide, I will be using the current
|
||||||
|
[latest commit](https://github.com/Nukestye/Zodiac/tree/213891a38af1b7ecbd068b661ef9062ab58cc818)
|
||||||
|
|
||||||
|
## Preparations
|
||||||
|
|
||||||
|
- First, create a Discordeno Bot using the [Generator Template](https://github.com/discordeno/template) I will name it
|
||||||
|
Zodiac.
|
||||||
|
|
||||||
|
- Then `git clone https://github.com/Skillz4Killz/Zodiac.git`
|
||||||
|
|
||||||
|
Now that I had the repository cloned, I could begin. Note that although the bot we are converting is built in
|
||||||
|
JavaScript, I converted all code to TypeScript in this Guide as Discordeno is designed to be the best lib for TypeScript
|
||||||
|
developers.
|
||||||
|
|
||||||
|
Time to get started!
|
||||||
|
|
||||||
|
## Converting main.js (index file)
|
||||||
|
|
||||||
|
The first thing is to convert the `main.js` file which would be the app.js or index.js file. This is the file that is
|
||||||
|
run to start your bot. In this case, the bot developer chose `main.js`. In Deno, the initial file is named `mod.ts` so
|
||||||
|
we can go ahead and opt for the Deno pattern. Note: there is already a `mod.ts` file created and prebuilt entirely using
|
||||||
|
the Generator.
|
||||||
|
|
||||||
|
Current Discord.JS Code:
|
||||||
|
|
||||||
|
```js
|
||||||
|
/* Keeping this to shoutout/credit the original author <3
|
||||||
|
* @author: nukestye
|
||||||
|
*/
|
||||||
|
|
||||||
|
const config = require("./config.json");
|
||||||
|
const fs = require("fs");
|
||||||
|
const log = console.log;
|
||||||
|
|
||||||
|
// Setting up the way to get commands
|
||||||
|
const { CommandoClient } = require("discord.js-commando");
|
||||||
|
const path = require("path");
|
||||||
|
|
||||||
|
// reading events
|
||||||
|
fs.readdir("./src/events/", (err, files) => {
|
||||||
|
if (err) return console.error(err);
|
||||||
|
files.forEach((file) => {
|
||||||
|
const eventFunction = require(`./src/events/${file}`);
|
||||||
|
if (eventFunction.disabled) return;
|
||||||
|
const event = eventFunction.event || file.split(".")[0];
|
||||||
|
const emitter =
|
||||||
|
(typeof eventFunction.emitter === "string" ? client[eventFunction.emitter] : eventFunction.emitter) || client;
|
||||||
|
const { once } = eventFunction;
|
||||||
|
try {
|
||||||
|
emitter[
|
||||||
|
once ? "once" : "on"
|
||||||
|
](event, (...args) => eventFunction.run(...args));
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error.stack);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const client = global.client = new CommandoClient({
|
||||||
|
commandPrefix: `${config.prefix}`,
|
||||||
|
owner: `${config.owner}`,
|
||||||
|
invite: `${config.discord}`,
|
||||||
|
unknownCommandResponse: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Registing the commands
|
||||||
|
client.registry
|
||||||
|
.registerDefaultTypes()
|
||||||
|
// The different fields for cmds
|
||||||
|
.registerGroups([
|
||||||
|
["mod", "Moderation Commands"],
|
||||||
|
["public", "Public Commands"],
|
||||||
|
])
|
||||||
|
.registerDefaultGroups()
|
||||||
|
// Basic cmds can be disabled like {"cmd: false"}
|
||||||
|
.registerDefaultCommands()
|
||||||
|
// commands in "/src/commands" will be counted
|
||||||
|
.registerCommandsIn(path.join(__dirname, "/src/commands"));
|
||||||
|
|
||||||
|
// list of activities that the bot goes through
|
||||||
|
const activityArray = [`${config.prefix}help | `];
|
||||||
|
// Bot lanuch code
|
||||||
|
client.once("ready", () => {
|
||||||
|
log(`Logged in as ${client.user.tag} in ${client.guilds.size} guild(s)!`);
|
||||||
|
setInterval(() => {
|
||||||
|
const index = Math.floor(Math.random() * (activityArray.length)); // generates a random number between 1 and the length of the activities array list
|
||||||
|
client.user.setActivity(
|
||||||
|
activityArray[index],
|
||||||
|
{
|
||||||
|
type: "PLAYING",
|
||||||
|
},
|
||||||
|
); // sets bot"s activities to one of the phrases in the arraylist.
|
||||||
|
}, 5000); // updates every 10000ms = 10s
|
||||||
|
});
|
||||||
|
// If an error print it out
|
||||||
|
client.on("error", console.error);
|
||||||
|
|
||||||
|
// Login in using the token in config
|
||||||
|
client.login(config.env.TOKEN);
|
||||||
|
```
|
||||||
|
|
||||||
|
Discordeno Version:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { botCache, Intents } from "./deps.ts";
|
||||||
|
import { configs } from "./configs.ts";
|
||||||
|
import { importDirectory } from "./src/utils/helpers.ts";
|
||||||
|
import { loadLanguages } from "./src/utils/i18next.ts";
|
||||||
|
|
||||||
|
console.info(
|
||||||
|
"Beginning Bot Startup Process. This can take a little bit depending on your system. Loading now...",
|
||||||
|
);
|
||||||
|
|
||||||
|
// Always require these files be processed before anything else
|
||||||
|
await Promise.all([
|
||||||
|
"./src/customizations/structures",
|
||||||
|
].map(
|
||||||
|
(path) => importDirectory(Deno.realPathSync(path)),
|
||||||
|
));
|
||||||
|
|
||||||
|
// Forces deno to read all the files which will fill the commands/inhibitors cache etc.
|
||||||
|
await Promise.all(
|
||||||
|
[
|
||||||
|
"./src/commands",
|
||||||
|
"./src/inhibitors",
|
||||||
|
"./src/events",
|
||||||
|
"./src/arguments",
|
||||||
|
"./src/monitors",
|
||||||
|
"./src/tasks",
|
||||||
|
"./src/permissionLevels",
|
||||||
|
"./src/events",
|
||||||
|
].map(
|
||||||
|
(path) => importDirectory(Deno.realPathSync(path)),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Loads languages
|
||||||
|
await loadLanguages();
|
||||||
|
await import("./src/database/database.ts");
|
||||||
|
|
||||||
|
startBot({
|
||||||
|
token: configs.token,
|
||||||
|
// Pick the intents you wish to have for your bot.
|
||||||
|
// For instance, to work with guild message reactions, you will have to pass the Intents.GUILD_MESSAGE_REACTIONS intent to the array.
|
||||||
|
intents: Intents.Guilds | Intents.GuildMessages,
|
||||||
|
// These are all your event handler functions. Imported from the events folder
|
||||||
|
events: botCache.events,
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
Something we haven't converted yet from the `main.js` files is the event listeners. To do that, we will open up the
|
||||||
|
events folder and find the corresponding event or create it if necessary. In this case, we have the `ready` event and
|
||||||
|
there is already a `ready.ts` file. We can just use that.
|
||||||
|
|
||||||
|
In our `ready.ts` file we can add the `ready` event listener.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { ActivityTypes, botCache, cache, chooseRandom, editBotStatus, StatusTypes } from "../../deps.ts";
|
||||||
|
import { registerTasks } from "./../utils/taskHelper.ts";
|
||||||
|
|
||||||
|
botCache.events.ready = function () {
|
||||||
|
editBotStatus(
|
||||||
|
StatusTypes.DoNotDisturb,
|
||||||
|
"Discordeno Best Lib",
|
||||||
|
ActivityTypes.Game,
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(`Loaded ${botCache.arguments.size} Argument(s)`);
|
||||||
|
console.log(`Loaded ${botCache.commands.size} Command(s)`);
|
||||||
|
console.log(`Loaded ${Object.keys(botCache.events).length} Event(s)`);
|
||||||
|
console.log(`Loaded ${botCache.inhibitors.size} Inhibitor(s)`);
|
||||||
|
console.log(`Loaded ${botCache.monitors.size} Monitor(s)`);
|
||||||
|
console.log(`Loaded ${botCache.tasks.size} Task(s)`);
|
||||||
|
|
||||||
|
registerTasks();
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
`[READY] Bot is online and ready in ${cache.guilds.size} guild(s)!`,
|
||||||
|
);
|
||||||
|
|
||||||
|
// list of activities that the bot goes through
|
||||||
|
const activityArray = [`${configs.prefix}help | `];
|
||||||
|
setInterval(() => {
|
||||||
|
const randomActivity = activityArray[Math.floor(Math.random() * activityArray.length)];
|
||||||
|
|
||||||
|
editBotStatus(botCache, {
|
||||||
|
activities: [{ name: randomActivity, type: ActivityTypes.Game, createdAt: Date.now() }],
|
||||||
|
status: "online",
|
||||||
|
});
|
||||||
|
}, 5000);
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
To understand this code, we are setting a function to be run when the bot is `ready`. Then the bot will edit the bot's
|
||||||
|
status every 5 seconds. Notice that you also have beautiful enums provided that prevents you from making any
|
||||||
|
typos/mistakes.
|
||||||
|
|
||||||
|
We have now converted the entire `main.js` file, in a matter of seconds. The Discordeno official generator took care of
|
||||||
|
the majority of workload and we just modified the `ready.ts` file.
|
||||||
|
|
||||||
|
`Note:` I did remove some generally well known "bad practices" such as global vars and such. Overall, you will see the
|
||||||
|
functionality of the project will not change as we progress through this guide.
|
||||||
|
|
||||||
|
## Converting Commands
|
||||||
|
|
||||||
|
The first command in the commands folder is the `addRole` command.
|
||||||
|
|
||||||
|
This is the code from the bot:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
// Getting the 'Command' features from Commando
|
||||||
|
const { Command } = require("discord.js-commando");
|
||||||
|
|
||||||
|
// Code for the command
|
||||||
|
module.exports = class addRoleCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
// name of the command, must be in lowercase
|
||||||
|
name: "addrole",
|
||||||
|
// other ways to call the command, must be in lowercase
|
||||||
|
aliases: ["role"],
|
||||||
|
// command group its part of
|
||||||
|
group: "mod",
|
||||||
|
// name within the command group, must be in lowercase
|
||||||
|
memberName: "addrole",
|
||||||
|
// Is the description used for 'help' command
|
||||||
|
description: "Adds mentioned role to mentioned user.",
|
||||||
|
// Prevents it from being used in dms
|
||||||
|
guildOnly: true,
|
||||||
|
// Permissions, list found here > `discord.js.org/#/docs/main/11.5.1/class/Permissions?scrollTo=s-FLAGS`
|
||||||
|
clientPermissions: ["ADMINISTRATOR", "MANAGE_ROLES"],
|
||||||
|
userPermissions: ["MANAGE_ROLES"],
|
||||||
|
// Prevents anyone other than owner to use the command
|
||||||
|
ownerOnly: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run code goes here
|
||||||
|
run(message) {
|
||||||
|
const user = message.mentions.members.first();
|
||||||
|
const roleToAdd = message.mentions.roles.first();
|
||||||
|
|
||||||
|
// checking to see if the user has the role or not
|
||||||
|
if (!(user.roles.find((r) => r.name === roleToAdd.name))) {
|
||||||
|
user.addRole(roleToAdd);
|
||||||
|
message.channel.send(`${user} has been given the role: ${roleToAdd.name}`)
|
||||||
|
.then((msg) => {
|
||||||
|
msg.delete(5000);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
message.channel.send(`${user} already has the role: ${roleToAdd.name}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.error(user, roleToAdd, message.member.roles.find(r => r.name === roleToAdd));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
This is how to do it with Discordeno:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { createCommand } from "./../../utils/helpers.ts";
|
||||||
|
|
||||||
|
createCommand({
|
||||||
|
name: "role",
|
||||||
|
// Oher ways to call the command
|
||||||
|
aliases: ["addrole"],
|
||||||
|
// Is the description used for 'help' command
|
||||||
|
description: "Adds mentioned role to mentioned user.",
|
||||||
|
// Prevents it from being used in dms
|
||||||
|
guildOnly: true,
|
||||||
|
botServerPermissions: ["ADMINISTRATOR", "MANAGE_ROLES"],
|
||||||
|
userServerPermissions: ["MANAGE_ROLES"],
|
||||||
|
arguments: [
|
||||||
|
{ name: "member", type: "member" },
|
||||||
|
{ name: "role", type: "role" },
|
||||||
|
],
|
||||||
|
execute: (bot, message, args) => {
|
||||||
|
// checking to see if the user has the role or not
|
||||||
|
if (!args.member.roles.includes(args.role.id)) {
|
||||||
|
bot.helpers.addRole(message.guildId, args.member.id, args.role.id);
|
||||||
|
bot.helpers.sendMessage(message.channelId, {
|
||||||
|
content: `${args.member.mention} has been given the role: ${args.role.name}`,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
bot.helpers.sendMessage(message.channelId, {
|
||||||
|
content: `${args.member.mention} already has the role: ${args.role.name}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
Awesome, that is a full command converted from Discord.JS to Discordeno. See how easy it is! Let's convert one more
|
||||||
|
command to see how to really take full advantage of Discordeno template and have something amazing.
|
||||||
|
|
||||||
|
Discord.JS Kick Command Version
|
||||||
|
|
||||||
|
```js
|
||||||
|
// Getting the 'Command' features from Commando
|
||||||
|
const { Command } = require("discord.js-commando");
|
||||||
|
const { RichEmbed } = require("discord.js");
|
||||||
|
const chalk = require("chalk");
|
||||||
|
const log = console.log;
|
||||||
|
|
||||||
|
// Code for the command
|
||||||
|
module.exports = class kickCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
// name of the command, must be in lowercase
|
||||||
|
name: "kick",
|
||||||
|
// other ways to call the command, must be in lowercase
|
||||||
|
aliases: ["boot", "tempban"],
|
||||||
|
// command group its part of
|
||||||
|
group: "mod",
|
||||||
|
// name within the command group, must be in lowercase
|
||||||
|
memberName: "kick",
|
||||||
|
// Is the description used for 'help' command
|
||||||
|
description: "Kick command.",
|
||||||
|
// adds cooldowns to the command
|
||||||
|
throttling: {
|
||||||
|
// usages in certain time x
|
||||||
|
usages: 1,
|
||||||
|
// the cooldown
|
||||||
|
duration: 10,
|
||||||
|
},
|
||||||
|
// Prevents it from being used in dms
|
||||||
|
guildOnly: true,
|
||||||
|
// Permissions, list found here > `discord.js.org/#/docs/main/11.5.1/class/Permissions?scrollTo=s-FLAGS`
|
||||||
|
clientPermissions: ["ADMINISTRATOR"],
|
||||||
|
userPermissions: ["KICK_MEMBERS"],
|
||||||
|
// Prevents anyone other than owner to use the command
|
||||||
|
ownerOnly: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run code goes here
|
||||||
|
run(message) {
|
||||||
|
const messageArry = message.content.split(" ");
|
||||||
|
const args = messageArry.slice(1);
|
||||||
|
|
||||||
|
const kUser = message.guild.member(
|
||||||
|
message.mentions.users.first() || message.guild.get(args[0]),
|
||||||
|
);
|
||||||
|
if (!kUser) return message.channel.send("User cannot be found!");
|
||||||
|
const kreason = args.join(" ").slice(22);
|
||||||
|
|
||||||
|
// setting up the embed for report/log
|
||||||
|
const kickEmbed = new RichEmbed()
|
||||||
|
.setDescription(`Report: ${kUser} Kick`)
|
||||||
|
.addField("Reason >", `${kreason}`)
|
||||||
|
.addField("Time", message.createdAt);
|
||||||
|
|
||||||
|
const reportchannel = message.guild.channels.find("name", "report");
|
||||||
|
if (!reportchannel) {
|
||||||
|
return message.channel.send("*`Report channel cannot be found!`*");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete the message command
|
||||||
|
// eslint-disable-next-line camelcase
|
||||||
|
message.delete().catch((O_o) => {});
|
||||||
|
// Kick the user with reason
|
||||||
|
message.guild.member(kUser).kick(kreason);
|
||||||
|
// sends the kick report into log/report
|
||||||
|
reportchannel.send(kickEmbed);
|
||||||
|
// Logs the kick into the terminal
|
||||||
|
log(chalk.red("KICK", chalk.underline.bgBlue(kUser) + "!"));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
Discordeno Version
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { createCommand } from "./../../utils/helpers.ts";
|
||||||
|
|
||||||
|
createCommand({
|
||||||
|
name: `kick`,
|
||||||
|
aliases: ["boot", "tempban"],
|
||||||
|
description: "Kick command.",
|
||||||
|
// adds cooldowns to the command
|
||||||
|
cooldown: {
|
||||||
|
// usages in certain duration of seconds below
|
||||||
|
allowedUses: 1,
|
||||||
|
// the cooldown
|
||||||
|
seconds: 10,
|
||||||
|
},
|
||||||
|
// Prevents it from being used in dms
|
||||||
|
guildOnly: true,
|
||||||
|
botServerPermissions: ["ADMINISTRATOR"],
|
||||||
|
userServerPermissions: ["KICK_MEMBERS"],
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: "member",
|
||||||
|
type: "member",
|
||||||
|
missing: function (message) {
|
||||||
|
message.reply(`User cannot be found.`);
|
||||||
|
},
|
||||||
|
// By default this is true but for the purpose of the guide so you can see this exists.
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "reason",
|
||||||
|
// The leftover string provided by the user that was not used by previous args.
|
||||||
|
type: "...string",
|
||||||
|
defaultValue: "No reason provided.",
|
||||||
|
// It is silly to lowercase this but for the purpose of the guide you can see that this is also available to you.
|
||||||
|
lowercase: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
execute: function (bot, message, args: KickArgs) {
|
||||||
|
// setting up the embed for report/log
|
||||||
|
const embed = new Embed()
|
||||||
|
.setDescription(`Report: ${args.member.mention} Kick`)
|
||||||
|
.addField("Reason >", args.reason)
|
||||||
|
.addField("Time", message.timestamp.toString());
|
||||||
|
|
||||||
|
const reportchannel = message.guild?.channels.find((channel) => channel.name === "report");
|
||||||
|
if (!reportchannel) {
|
||||||
|
return bot.helpers.sendMessage(message.channelId, { content: "*`Report channel cannot be found!`*" });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete the message command
|
||||||
|
bot.helpers.deleteMessage(message.channelId, { content: "Remove kick command trigger." });
|
||||||
|
// Kick the user with reason
|
||||||
|
bot.helpers.kickMember(message.guildId, args.member.id, args.reason);
|
||||||
|
// sends the kick report into log/report
|
||||||
|
bot.helpers.sendMessage(message.channelId, { embeds: [embed] });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
interface KickArgs {
|
||||||
|
member: Member;
|
||||||
|
reason: string;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Let's take a minute and explain the differences here. The first thing you will probably notice is different is the
|
||||||
|
`arguments` property. Discordeno provides the `arguments` property because it provides argument
|
||||||
|
handling/parsing/validating internally. You don't need to be splitting the message content or going through and
|
||||||
|
validating it yourself. All you do is tell Discordeno that you want a member and a reason. It will do the magic and hard
|
||||||
|
work to get you that data before you even run the command. You just do `args.member` and you have access to the full
|
||||||
|
member object. There are a lot more powerful aspects to Discordeno like arguments. Keep diving in and you will find all
|
||||||
|
the wonderful tools available to give you the best developer experience possible.
|
||||||
|
|
||||||
|
### Need More Examples/Help
|
||||||
|
|
||||||
|
If you still need more help converting other aspects of your bot please contact me at
|
||||||
|
[Discord](https://discord.com/invite/5vBgXk3UcZ). I will continue adding more examples to this guide as more people
|
||||||
|
request them.
|
||||||
@@ -1,8 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "site",
|
"name": "site",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
|
<<<<<<< HEAD:apps/site/package.json
|
||||||
|
"license": "Apache 2.0",
|
||||||
|
=======
|
||||||
"private": false,
|
"private": false,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
|
>>>>>>> 1a717ddc7d97e31d3775747df9df153729d2925d:site/package.json
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"docusaurus": "docusaurus",
|
"docusaurus": "docusaurus",
|
||||||
"start": "docusaurus start --host 0.0.0.0",
|
"start": "docusaurus start --host 0.0.0.0",
|
||||||
@@ -32,8 +36,12 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@docusaurus/module-type-aliases": "2.2.0",
|
"@docusaurus/module-type-aliases": "2.2.0",
|
||||||
"@tsconfig/docusaurus": "^1.0.4",
|
"@tsconfig/docusaurus": "^1.0.4",
|
||||||
|
<<<<<<< HEAD:apps/site/package.json
|
||||||
|
"typescript": "^4.9.3"
|
||||||
|
=======
|
||||||
"@types/chart.js": "^2.9.37",
|
"@types/chart.js": "^2.9.37",
|
||||||
"typescript": "^4.5.2"
|
"typescript": "^4.5.2"
|
||||||
|
>>>>>>> 1a717ddc7d97e31d3775747df9df153729d2925d:site/package.json
|
||||||
},
|
},
|
||||||
"browserslist": {
|
"browserslist": {
|
||||||
"production": [
|
"production": [
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/**
|
||||||
|
* Creating a sidebar enables you to:
|
||||||
|
- create an ordered group of docs
|
||||||
|
- render a sidebar for each doc of that group
|
||||||
|
- provide next/previous navigation
|
||||||
|
|
||||||
|
The sidebars can be generated from the filesystem, or explicitly defined here.
|
||||||
|
|
||||||
|
Create as many sidebars as you want.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @ts-check
|
||||||
|
|
||||||
|
/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
|
||||||
|
const sidebars = {
|
||||||
|
// By default, Docusaurus generates a sidebar from the docs folder structure
|
||||||
|
docs: [{ type: "autogenerated", dirName: "." }],
|
||||||
|
// But you can create a sidebar manually
|
||||||
|
/*
|
||||||
|
tutorialSidebar: [
|
||||||
|
{
|
||||||
|
type: 'category',
|
||||||
|
label: 'Tutorial',
|
||||||
|
items: ['hello'],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
*/
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = sidebars;
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user