generated from ShadowVR/AI_botter
Initial commit
This commit is contained in:
commit
376acc5d2c
4200 changed files with 603970 additions and 0 deletions
211
.idea/workspace.xml
Normal file
211
.idea/workspace.xml
Normal file
|
@ -0,0 +1,211 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AutoImportSettings">
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="b3f9e1bd-2718-42ef-a1bb-b0631aa9243f" name="Changes" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/.idea/.gitignore" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/.idea/AI_botter.iml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/@kwsites/file-exists/CHANGELOG.md" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/@kwsites/file-exists/LICENSE" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/@kwsites/file-exists/dist/index.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/@kwsites/file-exists/dist/index.js" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/@kwsites/file-exists/dist/index.js.map" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/@kwsites/file-exists/dist/src/index.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/@kwsites/file-exists/dist/src/index.js" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/@kwsites/file-exists/dist/src/index.js.map" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/@kwsites/file-exists/dist/test/__mocks__/fs.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/@kwsites/file-exists/dist/test/__mocks__/fs.js" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/@kwsites/file-exists/dist/test/__mocks__/fs.js.map" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/@kwsites/file-exists/dist/test/exists.spec.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/@kwsites/file-exists/dist/test/exists.spec.js" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/@kwsites/file-exists/dist/test/exists.spec.js.map" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/@kwsites/file-exists/package.json" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/@kwsites/file-exists/readme.md" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/@kwsites/promise-deferred/LICENSE" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/@kwsites/promise-deferred/dist/index.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/@kwsites/promise-deferred/dist/index.js" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/@kwsites/promise-deferred/dist/index.js.map" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/@kwsites/promise-deferred/package.json" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/debug/LICENSE" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/debug/README.md" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/debug/node_modules/ms/index.js" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/debug/node_modules/ms/license.md" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/debug/node_modules/ms/package.json" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/debug/node_modules/ms/readme.md" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/debug/package.json" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/debug/src/browser.js" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/debug/src/common.js" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/debug/src/index.js" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/debug/src/node.js" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/cjs/index.js" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/cjs/index.js.map" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/esm/index.js" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/esm/index.js.map" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/esm/package.json" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/api.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/args/log-format.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/args/pathspec.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/errors/git-construct-error.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/errors/git-error.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/errors/git-plugin-error.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/errors/git-response-error.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/errors/task-configuration-error.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/git-factory.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/git-logger.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/parsers/parse-branch-delete.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/parsers/parse-branch.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/parsers/parse-commit.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/parsers/parse-diff-summary.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/parsers/parse-fetch.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/parsers/parse-list-log-summary.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/parsers/parse-merge.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/parsers/parse-move.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/parsers/parse-pull.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/parsers/parse-push.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/parsers/parse-remote-messages.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/parsers/parse-remote-objects.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/plugins/abort-plugin.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/plugins/block-unsafe-operations-plugin.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/plugins/command-config-prefixing-plugin.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/plugins/completion-detection.plugin.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/plugins/custom-binary.plugin.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/plugins/error-detection.plugin.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/plugins/index.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/plugins/plugin-store.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/plugins/progress-monitor-plugin.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/plugins/simple-git-plugin.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/plugins/spawn-options-plugin.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/plugins/suffix-paths.plugin.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/plugins/timout-plugin.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/responses/BranchDeleteSummary.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/responses/BranchSummary.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/responses/CheckIgnore.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/responses/CleanSummary.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/responses/ConfigList.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/responses/DiffSummary.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/responses/FileStatusSummary.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/responses/GetRemoteSummary.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/responses/InitSummary.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/responses/MergeSummary.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/responses/PullSummary.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/responses/StatusSummary.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/responses/TagList.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/runners/git-executor-chain.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/runners/git-executor.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/runners/promise-wrapped.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/runners/scheduler.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/runners/tasks-pending-queue.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/simple-git-api.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/task-callback.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/apply-patch.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/branch.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/change-working-directory.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/check-ignore.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/check-is-repo.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/checkout.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/clean.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/clone.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/commit.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/config.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/diff-name-status.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/diff.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/fetch.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/first-commit.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/grep.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/hash-object.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/init.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/log.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/merge.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/move.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/pull.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/push.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/remote.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/reset.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/show.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/stash-list.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/status.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/sub-module.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/tag.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/task.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/tasks/version.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/types/handlers.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/types/index.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/types/tasks.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/utils/argument-filters.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/utils/exit-codes.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/utils/git-output-streams.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/utils/index.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/utils/line-parser.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/utils/simple-git-options.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/utils/task-options.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/utils/task-parser.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/src/lib/utils/util.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/typings/errors.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/typings/index.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/typings/response.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/typings/simple-git.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/dist/typings/types.d.ts" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/package.json" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/promise.js" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/node_modules/simple-git/readme.md" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/index.js" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/node_modules/.package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/.package-lock.json" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/package-lock.json" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="ProjectColorInfo"><![CDATA[{
|
||||
"associatedIndex": 1
|
||||
}]]></component>
|
||||
<component name="ProjectId" id="2h0UUgykFj17utdEDGfHR1uGm4Z" />
|
||||
<component name="ProjectViewState">
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"git-widget-placeholder": "main",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"ts.external.directory.path": "C:\\Users\\shaca\\AppData\\Local\\Programs\\WebStorm\\plugins\\javascript-plugin\\jsLanguageServicesImpl\\external",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
}
|
||||
}]]></component>
|
||||
<component name="SharedIndexes">
|
||||
<attachedChunks>
|
||||
<set>
|
||||
<option value="bundled-js-predefined-1d06a55b98c1-2e7d6887c066-JavaScript-WS-241.15989.47" />
|
||||
</set>
|
||||
</attachedChunks>
|
||||
</component>
|
||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="b3f9e1bd-2718-42ef-a1bb-b0631aa9243f" name="Changes" comment="" />
|
||||
<created>1716730506974</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1716730506974</updated>
|
||||
<workItem from="1716730508581" duration="956000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
<option name="version" value="3" />
|
||||
</component>
|
||||
</project>
|
64
README.md
Normal file
64
README.md
Normal file
|
@ -0,0 +1,64 @@
|
|||
# AI Bot
|
||||
|
||||
## Overview
|
||||
|
||||
The AI Bot is an advanced conversational agent powered by the GPT-3.5 and GPT-4 architectures. This bot is designed to provide comprehensive, intelligent, and context-aware responses, catering to a wide range of queries and tasks. Its capabilities extend across various domains, making it a versatile tool for users seeking assistance, information, or engagement in meaningful conversations.
|
||||
|
||||
## Key Features
|
||||
|
||||
### Multi-Model Capability
|
||||
- **GPT-3.5**: Offers a balance of performance and efficiency, capable of handling general queries, simple problem-solving, and everyday conversations.
|
||||
- **GPT-4**: Provides enhanced reasoning, context understanding, and sophisticated language generation, suitable for complex queries, in-depth discussions, and specialized tasks.
|
||||
|
||||
### Intelligent Response Generation
|
||||
- **Context Awareness**: Understands and retains context over multiple interactions, ensuring coherent and relevant responses.
|
||||
- **Adaptive Learning**: Continuously learns from interactions to improve response accuracy and relevance over time.
|
||||
|
||||
### Versatility
|
||||
- **Multi-Domain Expertise**: Equipped to handle queries from various domains such as technology, science, history, entertainment, and more.
|
||||
- **Task Performance**: Capable of performing tasks such as summarizing texts, translating languages, generating creative content, and providing technical support.
|
||||
|
||||
### Personalization
|
||||
- **User Profiling**: Adapts responses based on user preferences and previous interactions for a more personalized experience.
|
||||
- **Customizable Settings**: Allows users to customize response styles, tones, and preferences.
|
||||
|
||||
### Accessibility and Integration
|
||||
- **Cross-Platform Availability**: Accessible via web, mobile, and integrated into various applications and platforms.
|
||||
- **API Integration**: Offers API support for seamless integration with other software, enhancing functionality and user experience.
|
||||
|
||||
### Security and Privacy
|
||||
- **Data Encryption**: Ensures all user data and interactions are encrypted and secure.
|
||||
- **Privacy Compliance**: Adheres to global privacy standards and regulations to protect user information.
|
||||
|
||||
## Use Cases
|
||||
|
||||
### Customer Support
|
||||
- Provides instant, accurate, and 24/7 support to customers, improving satisfaction and reducing response times.
|
||||
|
||||
### Education
|
||||
- Assists students and educators by providing explanations, answering questions, and offering study resources.
|
||||
|
||||
### Content Creation
|
||||
- Helps writers, marketers, and content creators generate ideas, draft content, and edit texts efficiently.
|
||||
|
||||
### Personal Assistance
|
||||
- Acts as a virtual assistant to manage schedules, set reminders, and provide recommendations.
|
||||
|
||||
### Research and Development
|
||||
- Supports researchers by summarizing research papers, providing insights, and assisting in data analysis.
|
||||
|
||||
## Future Enhancements
|
||||
|
||||
The AI Bot is continually evolving, with future updates planned to include:
|
||||
- **Enhanced Emotional Intelligence**: Better understanding and responding to user emotions.
|
||||
- **Voice Interaction**: Adding support for voice queries and responses.
|
||||
- **Expanded Knowledge Base**: Continuously updated information across more domains.
|
||||
|
||||
## Conclusion
|
||||
|
||||
The AI Bot, leveraging the strengths of GPT-3.5 and GPT-4 models (current: GPT-4o), is a powerful tool designed to meet diverse user needs through intelligent, context-aware, and personalized interactions. Whether for personal use, professional assistance, or integration into larger systems, the AI Bot stands out as a versatile and reliable digital companion.
|
||||
|
||||
|
||||
## Newest update
|
||||
|
||||
The AI will send regular messages at less then 2000 characters, embeds at less then 4096, and .txt files at more then 4096 characters!
|
52
bot.js
Normal file
52
bot.js
Normal file
|
@ -0,0 +1,52 @@
|
|||
const simpleGit = require('simple-git');
|
||||
const path = require('path');
|
||||
const { exec } = require('child_process');
|
||||
|
||||
async function updateBotFromGitHub() {
|
||||
const git = simpleGit(path.resolve(__dirname));
|
||||
|
||||
try {
|
||||
console.log('Checking for updates from GitHub...');
|
||||
|
||||
if (!await git.checkIsRepo()) {
|
||||
await git.init().addRemote('origin', 'https://git.shadowhosting.xyz/shadowvr/AI_botter.git').fetch();
|
||||
} else {
|
||||
await git.fetch('origin', 'main');
|
||||
}
|
||||
|
||||
// Force update by resetting to the latest commit on the remote main branch
|
||||
await git.reset(['--hard', 'origin/main']);
|
||||
|
||||
console.log('Bot updated from GitHub.');
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error updating bot from GitHub:', error);
|
||||
}
|
||||
}
|
||||
|
||||
function startIndexJs() {
|
||||
console.log('Starting index.js...');
|
||||
const indexProcess = exec('node index.js', {
|
||||
cwd: path.resolve(__dirname),
|
||||
});
|
||||
|
||||
indexProcess.stdout.on('data', (data) => {
|
||||
console.log(data.toString());
|
||||
});
|
||||
|
||||
indexProcess.stderr.on('data', (data) => {
|
||||
console.error(data.toString());
|
||||
});
|
||||
|
||||
indexProcess.on('exit', (code) => {
|
||||
console.log(`index.js process exited with code ${code}`);
|
||||
});
|
||||
}
|
||||
|
||||
async function updateAndStartIndexJs() {
|
||||
await updateBotFromGitHub();
|
||||
startIndexJs();
|
||||
}
|
||||
|
||||
// Perform initial update and start index.js
|
||||
updateAndStartIndexJs();
|
264
commands/interactions/ask.js
Normal file
264
commands/interactions/ask.js
Normal file
|
@ -0,0 +1,264 @@
|
|||
const Discord = require('discord.js');
|
||||
const openAI = require('openai');
|
||||
const chalk = require('chalk');
|
||||
const fs = require('node:fs');
|
||||
const func = require('../../utils/functions');
|
||||
const settings = require('../../utils/settings');
|
||||
const config = require('../../configs/config.json');
|
||||
|
||||
module.exports = {
|
||||
data: new Discord.SlashCommandBuilder()
|
||||
.setName("ask")
|
||||
.setDescription("Answers your questions!")
|
||||
.addStringOption(option => option
|
||||
.setName("prompt")
|
||||
.setDescription("What is your question?")
|
||||
.setRequired(true)
|
||||
)
|
||||
.addStringOption(option => option
|
||||
.setName("model")
|
||||
.setDescription("What model do you want to ask from? (Default: GPT 3.5)")
|
||||
.setChoices(
|
||||
{
|
||||
name: 'GPT-3.5 (Cheaper)',
|
||||
value: 'gpt-3.5'
|
||||
},
|
||||
{
|
||||
name: 'GPT-4 (Smarter)',
|
||||
value: 'gpt-4'
|
||||
}
|
||||
)
|
||||
.setRequired(false)
|
||||
)
|
||||
.addStringOption(option => option
|
||||
.setName('stream')
|
||||
.setDescription('Streams the bot\'s response. (Default: Disable)')
|
||||
.addChoices(
|
||||
{
|
||||
name: 'Enable',
|
||||
value: 'Enable'
|
||||
},
|
||||
{
|
||||
name: 'Disable',
|
||||
value: 'Disable'
|
||||
}
|
||||
)
|
||||
.setRequired(false)
|
||||
)
|
||||
.addStringOption(option => option
|
||||
.setName('ephemeral')
|
||||
.setDescription('Hides the bot\'s reply from others. (Default: Disable)')
|
||||
.addChoices(
|
||||
{
|
||||
name: 'Enable',
|
||||
value: 'Enable'
|
||||
},
|
||||
{
|
||||
name: 'Disable',
|
||||
value: 'Disable'
|
||||
}
|
||||
)
|
||||
.setRequired(false)
|
||||
),
|
||||
|
||||
async execute(client, interaction) {
|
||||
|
||||
const ephemeralChoice = interaction.options.getString('ephemeral');
|
||||
const ephemeral = ephemeralChoice === 'Enable' ? true : false;
|
||||
|
||||
await interaction.deferReply({ ephemeral: ephemeral });
|
||||
|
||||
const streamChoice = interaction.options.getString('stream');
|
||||
const stream = streamChoice === 'Enable' ? true : false;
|
||||
|
||||
const openai = new openAI.OpenAI({ apiKey: config.OpenAIapiKey });
|
||||
|
||||
const question = interaction.options.getString("prompt");
|
||||
|
||||
const model = interaction.options.getString('model') || 'gpt-3.5';
|
||||
const modelNames = {
|
||||
'gpt-3.5': 'gpt-3.5-turbo',
|
||||
'gpt-4': 'gpt-4'
|
||||
};
|
||||
|
||||
const completionPrompt = fs.readFileSync(`./utils/prompts/${model === 'chatgpt' || model === 'davinci' ? 'chatCompletion' : 'completion'}.txt`, "utf-8");
|
||||
const prompt = completionPrompt
|
||||
.replaceAll('{botUsername}', client.user.username)
|
||||
.replaceAll('{userUsername}', interaction.user.username)
|
||||
.replaceAll('{question}', question);
|
||||
|
||||
const messages = [
|
||||
{
|
||||
"role": "system",
|
||||
"content": prompt
|
||||
},
|
||||
{
|
||||
"role": 'user',
|
||||
"content": question
|
||||
}
|
||||
];
|
||||
|
||||
const completion = await openai.chat.completions.create({
|
||||
|
||||
model: modelNames[model],
|
||||
messages: messages,
|
||||
max_tokens: func.tokenizer(model, messages).maxTokens,
|
||||
temperature: settings.completion.temprature,
|
||||
top_p: settings.completion.top_p,
|
||||
frequency_penalty: settings.completion.frequency_penalty,
|
||||
presence_penalty: settings.completion.presence_penalty,
|
||||
stream: stream
|
||||
|
||||
}).catch(async (error) => {
|
||||
|
||||
console.error(chalk.bold.redBright(error));
|
||||
|
||||
if (error.response) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.ErrorColor)
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: interaction.user.displayAvatarURL()
|
||||
})
|
||||
.setDescription(error.response.error.message.length > 4096 ? error.response.error.message.substring(0, 4093) + "..." : error.response.error.message);
|
||||
|
||||
await interaction.editReply({ embeds: [embed] }).catch(() => null);
|
||||
|
||||
} else if (error.message) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.ErrorColor)
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: interaction.user.displayAvatarURL()
|
||||
})
|
||||
.setDescription(error.message.length > 4096 ? error.message.substring(0, 4093) + "..." : error.message);
|
||||
|
||||
await interaction.editReply({ embeds: [embed] }).catch(() => null);
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
if (!stream) {
|
||||
|
||||
const answer = completion.choices[0].message.content;
|
||||
const usage = completion.usage;
|
||||
|
||||
if (answer.length <= 4096) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.MainColor)
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: interaction.user.displayAvatarURL()
|
||||
})
|
||||
.setDescription(answer)
|
||||
.setFooter({
|
||||
text: `Costs ${func.pricing(model, usage.total_tokens)}`,
|
||||
iconURL: client.user.displayAvatarURL()
|
||||
});
|
||||
|
||||
await interaction.editReply({ embeds: [embed] });
|
||||
|
||||
} else {
|
||||
|
||||
const attachment = new Discord.AttachmentBuilder(
|
||||
Buffer.from(`${question}\n\n${answer}`, 'utf-8'),
|
||||
{ name: 'response.txt' }
|
||||
);
|
||||
|
||||
await interaction.editReply({ files: [attachment] });
|
||||
|
||||
};
|
||||
|
||||
} else {
|
||||
|
||||
let fullAnswer = "";
|
||||
let answer = "";
|
||||
|
||||
for await (const part of completion) {
|
||||
|
||||
if (part.choices[0]?.finish_reason === 'stop') {
|
||||
|
||||
const fullmessages = [
|
||||
{
|
||||
"role": "system",
|
||||
"content": prompt
|
||||
},
|
||||
{
|
||||
"role": 'user',
|
||||
"content": question
|
||||
},
|
||||
{
|
||||
"role": 'assistant',
|
||||
"content": fullAnswer
|
||||
},
|
||||
];
|
||||
|
||||
const totalTokens = func.tokenizer(model, fullmessages).tokens;
|
||||
|
||||
if (fullAnswer.length <= 4096) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.MainColor)
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: interaction.user.displayAvatarURL()
|
||||
})
|
||||
.setDescription(fullAnswer)
|
||||
.setFooter({
|
||||
text: `Costs ${func.pricing(model, totalTokens)}`,
|
||||
iconURL: client.user.displayAvatarURL()
|
||||
});
|
||||
|
||||
await interaction.editReply({ embeds: [embed] });
|
||||
|
||||
} else {
|
||||
|
||||
const attachment = new Discord.AttachmentBuilder(
|
||||
Buffer.from(`${question}\n\n${fullAnswer}\n\nCosts ${func.pricing(model, totalTokens)}`, 'utf-8'),
|
||||
{ name: 'response.txt' }
|
||||
);
|
||||
|
||||
await interaction.editReply({ embeds: [], files: [attachment] });
|
||||
|
||||
};
|
||||
|
||||
} else {
|
||||
|
||||
if (answer.includes('\n\n') && fullAnswer.length <= 4096) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.MainColor)
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: interaction.user.displayAvatarURL()
|
||||
})
|
||||
.setDescription(fullAnswer)
|
||||
.setFooter({
|
||||
text: `Writing...`,
|
||||
iconURL: client.user.displayAvatarURL()
|
||||
});
|
||||
|
||||
await interaction.editReply({ embeds: [embed] });
|
||||
|
||||
answer = "";
|
||||
|
||||
await func.delay(5000);
|
||||
|
||||
};
|
||||
|
||||
answer += part.choices[0]?.delta?.content || '';
|
||||
fullAnswer += part.choices[0]?.delta?.content || '';
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
},
|
||||
|
||||
};
|
49
commands/interactions/help.js
Normal file
49
commands/interactions/help.js
Normal file
|
@ -0,0 +1,49 @@
|
|||
const Discord = require('discord.js');
|
||||
const config = require('../../configs/config.json');
|
||||
const { chatbot } = require('../../configs/chatbot');
|
||||
|
||||
module.exports = {
|
||||
data: new Discord.SlashCommandBuilder()
|
||||
.setName("help")
|
||||
.setDescription("Shows the Bot's commands list and information.")
|
||||
.addStringOption(option => option
|
||||
.setName('ephemeral')
|
||||
.setDescription('Hides the bot\'s reply from others. (Default: Disable)')
|
||||
.addChoices(
|
||||
{
|
||||
name: 'Enable',
|
||||
value: 'Enable'
|
||||
},
|
||||
{
|
||||
name: 'Disable',
|
||||
value: 'Disable'
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
async execute(client, interaction) {
|
||||
|
||||
const ephemeralChoice = interaction.options.getString('ephemeral');
|
||||
const ephemeral = ephemeralChoice === 'Enable' ? true : false;
|
||||
await interaction.deferReply({ ephemeral: ephemeral });
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.MainColor)
|
||||
.setAuthor({
|
||||
name: `${client.user.username} Commands`,
|
||||
iconURL: client.user.displayAvatarURL({ size: 1024 })
|
||||
})
|
||||
.setDescription(client.MessageCommands.map(c => `> \`${config.Prefix}${c.name}\` \`(${c.aliases?.map(a => `${config.Prefix}${a}`)?.join(' / ') || 'No Aliases'})\`\n> *${c.description}*`).join('\n\n'))
|
||||
.setFooter({ text: 'Developed by iTz Arshia https://github.com/iTzArshia/GPT-Discord-Bot' });
|
||||
|
||||
if (chatbot.State) embed.addFields({
|
||||
name: 'ChatBot:',
|
||||
value: `Channel: <#${chatbot.ChatBotChannel}>`,
|
||||
inline: true
|
||||
});
|
||||
|
||||
await interaction.editReply({ embeds: [embed] });
|
||||
|
||||
},
|
||||
|
||||
};
|
135
commands/interactions/imagine.js
Normal file
135
commands/interactions/imagine.js
Normal file
|
@ -0,0 +1,135 @@
|
|||
const Discord = require('discord.js');
|
||||
const openAI = require('openai');
|
||||
const chalk = require('chalk');
|
||||
const func = require('../../utils/functions');
|
||||
const config = require('../../configs/config.json');
|
||||
|
||||
module.exports = {
|
||||
data: new Discord.SlashCommandBuilder()
|
||||
.setName("imagine")
|
||||
.setDescription("Draw your imaginations!")
|
||||
.addStringOption(option => option
|
||||
.setName("prompt")
|
||||
.setDescription("What is your imagine?")
|
||||
.setRequired(true)
|
||||
)
|
||||
.addStringOption(option => option
|
||||
.setName('ephemeral')
|
||||
.setDescription('Hides the bot\'s reply from others. (Default: Disable)')
|
||||
.addChoices(
|
||||
{
|
||||
name: 'Enable',
|
||||
value: 'Enable'
|
||||
},
|
||||
{
|
||||
name: 'Disable',
|
||||
value: 'Disable'
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
async execute(client, interaction) {
|
||||
|
||||
const ephemeralChoice = interaction.options.getString('ephemeral');
|
||||
const ephemeral = ephemeralChoice === 'Enable' ? true : false;
|
||||
await interaction.deferReply({ ephemeral: ephemeral });
|
||||
|
||||
const openai = new openAI.OpenAI({ apiKey: config.OpenAIapiKey });
|
||||
|
||||
const question = interaction.options.getString("prompt");
|
||||
|
||||
openai.images.generate({
|
||||
|
||||
prompt: question,
|
||||
n: 4,
|
||||
size: '1024x1024'
|
||||
|
||||
}).then(async (response) => {
|
||||
|
||||
const data = response.data;
|
||||
|
||||
const embeds = [
|
||||
|
||||
new Discord.EmbedBuilder()
|
||||
.setColor(config.MainColor)
|
||||
.setURL('https://github.com/iTzArshia/GPT-Discord-Bot')
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: interaction.user.displayAvatarURL()
|
||||
})
|
||||
.setImage(data[0].url)
|
||||
.setFooter({
|
||||
text: `Costs ${func.pricing('dall.e', 4, '1024x1024')}`,
|
||||
iconURL: client.user.displayAvatarURL()
|
||||
})
|
||||
|
||||
];
|
||||
|
||||
const buttons = [
|
||||
|
||||
new Discord.ButtonBuilder()
|
||||
.setStyle(Discord.ButtonStyle.Link)
|
||||
.setLabel('Image 1')
|
||||
.setURL(data[0].url)
|
||||
|
||||
];
|
||||
|
||||
for (let i = 0; i < 3; i++) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setURL('https://github.com/iTzArshia/GPT-Discord-Bot')
|
||||
.setImage(data[i + 1].url);
|
||||
|
||||
const button = new Discord.ButtonBuilder()
|
||||
.setStyle(Discord.ButtonStyle.Link)
|
||||
.setLabel(`Image ${i + 2}`)
|
||||
.setURL(data[i + 1].url)
|
||||
|
||||
embeds.push(embed);
|
||||
buttons.push(button);
|
||||
|
||||
};
|
||||
|
||||
const row = new Discord.ActionRowBuilder()
|
||||
.addComponents(buttons);
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: embeds,
|
||||
components: [row]
|
||||
});
|
||||
|
||||
}).catch(async (error) => {
|
||||
|
||||
console.error(chalk.bold.redBright(error));
|
||||
|
||||
if (error.response) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.ErrorColor)
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: interaction.user.displayAvatarURL()
|
||||
})
|
||||
.setDescription(error.response.error.message.length > 4096 ? error.response.error.message.substring(0, 4093) + "..." : error.response.error.message);
|
||||
|
||||
await interaction.editReply({ embeds: [embed] }).catch(() => null);
|
||||
|
||||
} else if (error.message) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.ErrorColor)
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: interaction.user.displayAvatarURL()
|
||||
})
|
||||
.setDescription(error.message.length > 4096 ? error.message.substring(0, 4093) + "..." : error.message);
|
||||
|
||||
await interaction.editReply({ embeds: [embed] }).catch(() => null);
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
};
|
133
commands/interactions/optimize.js
Normal file
133
commands/interactions/optimize.js
Normal file
|
@ -0,0 +1,133 @@
|
|||
const Discord = require('discord.js');
|
||||
const openAI = require('openai');
|
||||
const chalk = require('chalk');
|
||||
const fs = require('node:fs');
|
||||
const func = require('../../utils/functions');
|
||||
const settings = require('../../utils/settings');
|
||||
const config = require('../../configs/config.json');
|
||||
|
||||
module.exports = {
|
||||
data: new Discord.SlashCommandBuilder()
|
||||
.setName("optimize")
|
||||
.setDescription("Optimizes your imaginations to get better response with draw!")
|
||||
.addStringOption(option => option
|
||||
.setName("prompt")
|
||||
.setDescription("What is your imagine?")
|
||||
.setRequired(true)
|
||||
)
|
||||
.addStringOption(option => option
|
||||
.setName('ephemeral')
|
||||
.setDescription('Hides the bot\'s reply from others. (Default: Disable)')
|
||||
.addChoices(
|
||||
{
|
||||
name: 'Enable',
|
||||
value: 'Enable'
|
||||
},
|
||||
{
|
||||
name: 'Disable',
|
||||
value: 'Disable'
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
async execute(client, interaction) {
|
||||
|
||||
const ephemeralChoice = interaction.options.getString('ephemeral');
|
||||
const ephemeral = ephemeralChoice === 'Enable' ? true : false;
|
||||
await interaction.deferReply({ ephemeral: ephemeral });
|
||||
|
||||
const openai = new openAI.OpenAI({ apiKey: config.OpenAIapiKey });
|
||||
|
||||
const question = interaction.options.getString("prompt");
|
||||
|
||||
const optimizerPrompt = fs.readFileSync("./utils/prompts/optimizer.txt", "utf-8");
|
||||
const prompt = optimizerPrompt + question + ".";
|
||||
|
||||
const messages = [{
|
||||
"role": 'user',
|
||||
"content": prompt
|
||||
}];
|
||||
|
||||
openai.chat.completions.create({
|
||||
|
||||
model: 'gpt-3.5-turbo',
|
||||
messages: messages,
|
||||
max_tokens: func.tokenizer('gpt-3.5', messages).maxTokens,
|
||||
temperature: settings.optimzer.temprature,
|
||||
top_p: settings.optimzer.top_p,
|
||||
frequency_penalty: settings.optimzer.frequency_penalty,
|
||||
presence_penalty: settings.optimzer.presence_penalty
|
||||
|
||||
}).then(async (response) => {
|
||||
|
||||
const answer = response.choices[0].message.content
|
||||
.replace("Optimized Prompt:", "")
|
||||
.replace("Optimized prompt:", "")
|
||||
.replace("Optimized Output:", "")
|
||||
.replace("Optimized output:", "")
|
||||
.replace("Output:", "")
|
||||
.replace("output:", "");
|
||||
|
||||
const usage = response.usage;
|
||||
|
||||
if (answer.length <= 4096) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.MainColor)
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: interaction.user.displayAvatarURL()
|
||||
})
|
||||
.setDescription(answer)
|
||||
.setFooter({
|
||||
text: `Costs ${func.pricing('gpt-3.5', usage.total_tokens)}`,
|
||||
iconURL: client.user.displayAvatarURL()
|
||||
});
|
||||
|
||||
await interaction.editReply({ embeds: [embed] });
|
||||
|
||||
} else {
|
||||
|
||||
const attachment = new Discord.AttachmentBuilder(
|
||||
Buffer.from(`${question}\n\n${answer}`, 'utf-8'),
|
||||
{ name: 'response.txt' }
|
||||
);
|
||||
await interaction.editReply({ files: [attachment] });
|
||||
|
||||
};
|
||||
|
||||
}).catch(async (error) => {
|
||||
|
||||
console.error(chalk.bold.redBright(error));
|
||||
|
||||
if (error.response) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.ErrorColor)
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: interaction.user.displayAvatarURL()
|
||||
})
|
||||
.setDescription(error.response.error.message.length > 4096 ? error.response.error.message.substring(0, 4093) + "..." : error.response.error.message);
|
||||
|
||||
await interaction.editReply({ embeds: [embed] }).catch(() => null);
|
||||
|
||||
} else if (error.message) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.ErrorColor)
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: interaction.user.displayAvatarURL()
|
||||
})
|
||||
.setDescription(error.message.length > 4096 ? error.message.substring(0, 4093) + "..." : error.message);
|
||||
|
||||
await interaction.editReply({ embeds: [embed] }).catch(() => null);
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
};
|
63
commands/interactions/ping.js
Normal file
63
commands/interactions/ping.js
Normal file
|
@ -0,0 +1,63 @@
|
|||
const Discord = require('discord.js');
|
||||
const os = require('node:os');
|
||||
const func = require('../../utils/functions');
|
||||
const config = require('../../configs/config.json');
|
||||
|
||||
module.exports = {
|
||||
data: new Discord.SlashCommandBuilder()
|
||||
.setName("ping")
|
||||
.setDescription("Shows the bot\'s latency.")
|
||||
.addStringOption(option => option
|
||||
.setName('ephemeral')
|
||||
.setDescription('Hides the bot\'s reply from others. (Default: Disable)')
|
||||
.addChoices(
|
||||
{
|
||||
name: 'Enable',
|
||||
value: 'Enable'
|
||||
},
|
||||
{
|
||||
name: 'Disable',
|
||||
value: 'Disable'
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
async execute(client, interaction) {
|
||||
|
||||
const ephemeralChoice = interaction.options.getString('ephemeral');
|
||||
const ephemeral = ephemeralChoice === 'Enable' ? true : false;
|
||||
await interaction.deferReply({ ephemeral: ephemeral });
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.MainColor)
|
||||
.setAuthor({
|
||||
name: `Pong!`,
|
||||
iconURL: client.user.displayAvatarURL({ size: 1024 })
|
||||
})
|
||||
.addFields(
|
||||
{
|
||||
name: `📡 Ping:`,
|
||||
value: `${client.ws.ping}ms`,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: `💾 Memory:`,
|
||||
value: `${func.numberWithCommas(Math.round((process.memoryUsage().rss / 1024 / 1024)))}/${func.numberWithCommas(Math.round(os.totalmem() / 1024 / 1024))}MB`,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: `⏳ Uptime:`,
|
||||
value: func.timestamp(client.readyTimestamp),
|
||||
inline: false
|
||||
},
|
||||
)
|
||||
.setFooter({
|
||||
text: `Commanded by ${interaction.user.tag}`,
|
||||
iconURL: interaction.user.displayAvatarURL({ size: 1024 })
|
||||
});
|
||||
|
||||
await interaction.editReply({ embeds: [embed] });
|
||||
|
||||
},
|
||||
|
||||
};
|
142
commands/interactions/translate.js
Normal file
142
commands/interactions/translate.js
Normal file
|
@ -0,0 +1,142 @@
|
|||
const Discord = require('discord.js');
|
||||
const openAI = require('openai');
|
||||
const chalk = require('chalk');
|
||||
const fs = require('node:fs');
|
||||
const func = require('../../utils/functions');
|
||||
const settings = require('../../utils/settings');
|
||||
const config = require('../../configs/config.json');
|
||||
|
||||
module.exports = {
|
||||
data: new Discord.SlashCommandBuilder()
|
||||
.setName("translate")
|
||||
.setDescription("Translate your texts from any language to any language!")
|
||||
.addStringOption(option => option
|
||||
.setName("prompt")
|
||||
.setDescription("What is your text?")
|
||||
.setRequired(true)
|
||||
)
|
||||
.addStringOption(option => option
|
||||
.setName("language")
|
||||
.setDescription("What language would you like me to translate your prompt into? (Default: English)")
|
||||
.setRequired(false)
|
||||
)
|
||||
.addStringOption(option => option
|
||||
.setName('ephemeral')
|
||||
.setDescription('Hides the bot\'s reply from others. (Default: Disable)')
|
||||
.addChoices(
|
||||
{
|
||||
name: 'Enable',
|
||||
value: 'Enable'
|
||||
},
|
||||
{
|
||||
name: 'Disable',
|
||||
value: 'Disable'
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
async execute(client, interaction) {
|
||||
|
||||
const ephemeralChoice = interaction.options.getString('ephemeral');
|
||||
const ephemeral = ephemeralChoice === 'Enable' ? true : false;
|
||||
await interaction.deferReply({ ephemeral: ephemeral });
|
||||
|
||||
const openai = new openAI.OpenAI({ apiKey: config.OpenAIapiKey });
|
||||
|
||||
const question = interaction.options.getString("prompt");
|
||||
|
||||
const language = interaction.options.getString("language") || 'English';
|
||||
const translatorPrompt = fs.readFileSync("./utils/prompts/translator.txt", "utf-8");
|
||||
const prompt = translatorPrompt.replaceAll('{language}', language);
|
||||
|
||||
const messages = [
|
||||
{
|
||||
"role": "system",
|
||||
"content": prompt
|
||||
},
|
||||
{
|
||||
"role": 'user',
|
||||
"content": question
|
||||
}
|
||||
];
|
||||
|
||||
openai.chat.completions.create({
|
||||
|
||||
model: 'gpt-3.5-turbo',
|
||||
messages: messages,
|
||||
max_tokens: func.tokenizer('gpt-3.5', messages).maxTokens,
|
||||
temperature: settings.translator.temprature,
|
||||
top_p: settings.translator.top_p,
|
||||
frequency_penalty: settings.translator.frequency_penalty,
|
||||
presence_penalty: settings.translator.presence_penalty
|
||||
|
||||
}).then(async (response) => {
|
||||
|
||||
const answer = response.choices[0].message.content;
|
||||
const usage = response.usage;
|
||||
|
||||
if (answer.length <= 4096) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.MainColor)
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: interaction.user.displayAvatarURL()
|
||||
})
|
||||
.setDescription(answer)
|
||||
.setFooter({
|
||||
text: `Costs ${func.pricing('gpt-3.5', usage.total_tokens)}`,
|
||||
iconURL: client.user.displayAvatarURL()
|
||||
});
|
||||
|
||||
await interaction.editReply({ embeds: [embed] });
|
||||
|
||||
} else {
|
||||
|
||||
const attachment = new Discord.AttachmentBuilder(
|
||||
Buffer.from(`${question}\n\n${answer}`, 'utf-8'),
|
||||
{ name: 'response.txt' }
|
||||
);
|
||||
await interaction.editReply({ files: [attachment] });
|
||||
|
||||
};
|
||||
|
||||
}).catch(async (error) => {
|
||||
|
||||
console.error(chalk.bold.redBright(error));
|
||||
|
||||
if (error.response) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.ErrorColor)
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: interaction.user.displayAvatarURL()
|
||||
})
|
||||
.setDescription(error.response.error.message.length > 4096 ? error.response.error.message.substring(0, 4093) + "..." : error.response.error.message);
|
||||
|
||||
await interaction.editReply({ embeds: [embed] }).catch(() => null);
|
||||
|
||||
} else if (error.message) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.ErrorColor)
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: interaction.user.displayAvatarURL()
|
||||
})
|
||||
.setDescription(error.message.length > 4096 ? error.message.substring(0, 4093) + "..." : error.message);
|
||||
|
||||
await interaction.editReply({ embeds: [embed] }).catch(() => null);
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
};
|
43
commands/interactions/update.js
Normal file
43
commands/interactions/update.js
Normal file
|
@ -0,0 +1,43 @@
|
|||
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
const config = require('../../configs/config.json');
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('log')
|
||||
.setDescription('Send an embed message to one or more log channels')
|
||||
.addStringOption(option =>
|
||||
option.setName('content')
|
||||
.setDescription('Content for the log message')
|
||||
.setRequired(true))
|
||||
.addChannelOption(option =>
|
||||
option.setName('channels')
|
||||
.setDescription('Log channels to send the message to')
|
||||
.setRequired(true)),
|
||||
|
||||
async execute(interaction) {
|
||||
const content = interaction.options.getString('content');
|
||||
const channels = interaction.options.getChannel('channels');
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(config.LogColor)
|
||||
.setTitle(content)
|
||||
.setTimestamp()
|
||||
.setFooter(`Logged by ${interaction.user.tag}`, interaction.user.displayAvatarURL({ dynamic: true }));
|
||||
|
||||
try {
|
||||
// Iterate over the channels provided and send the message to each one
|
||||
for (const channel of channels) {
|
||||
// Check if the bot has permissions to send messages to the channel
|
||||
if (!channel.permissionsFor(interaction.client.user).has('SEND_MESSAGES')) {
|
||||
return interaction.reply(`I don't have permission to send messages to ${channel.toString()}.`);
|
||||
}
|
||||
await channel.send({ embeds: [embed] });
|
||||
}
|
||||
return interaction.reply({ content: "Embed message sent to the log channel(s) successfully!", ephemeral: true });
|
||||
} catch (error) {
|
||||
console.error("Error sending message:", error);
|
||||
return interaction.reply({ content: "There was an error sending the message to one or more log channels. Please try again later.", ephemeral: true });
|
||||
}
|
||||
},
|
||||
};
|
124
commands/messages/ask-gpt 3.5.js
Normal file
124
commands/messages/ask-gpt 3.5.js
Normal file
|
@ -0,0 +1,124 @@
|
|||
const Discord = require('discord.js');
|
||||
const openAI = require('openai');
|
||||
const chalk = require('chalk');
|
||||
const fs = require('node:fs');
|
||||
const func = require('../../utils/functions');
|
||||
const settings = require('../../utils/settings');
|
||||
const config = require('../../configs/config.json');
|
||||
|
||||
module.exports = {
|
||||
name: "Ask",
|
||||
aliases: ['A', 'GPT3.5', 'GPT-3.5'],
|
||||
description: "Answers your questions using __GPT-3.5__ model! **(Cheaper)**",
|
||||
|
||||
async execute(client, message, args, cmd) {
|
||||
|
||||
await message.channel.sendTyping();
|
||||
|
||||
if (!args[0]) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.ErrorColor)
|
||||
.setTitle('Error')
|
||||
.setDescription(`You can't use the \`${cmd}\` command like this you have to provide something like the example\n\`\`\`\n${config.Prefix}${cmd} Explain loops in JavaScript.\n\`\`\``);
|
||||
|
||||
await message.reply({ embeds: [embed] });
|
||||
|
||||
} else {
|
||||
|
||||
const openai = new openAI.OpenAI({ apiKey: config.OpenAIapiKey });
|
||||
|
||||
const question = args.join(" ");
|
||||
|
||||
const completionPrompt = fs.readFileSync("./utils/prompts/completion.txt", "utf-8");
|
||||
const prompt = completionPrompt.replaceAll('{botUsername}', client.user.username);
|
||||
const messages = [
|
||||
{
|
||||
"role": "system",
|
||||
"content": prompt
|
||||
},
|
||||
{
|
||||
"role": 'user',
|
||||
"content": question
|
||||
}
|
||||
];
|
||||
|
||||
openai.chat.completions.create({
|
||||
|
||||
model: 'gpt-3.5-turbo',
|
||||
messages: messages,
|
||||
max_tokens: func.tokenizer('gpt-3.5', messages).maxTokens,
|
||||
temperature: settings.completion.temprature,
|
||||
top_p: settings.completion.top_p,
|
||||
frequency_penalty: settings.completion.frequency_penalty,
|
||||
presence_penalty: settings.completion.presence_penalty
|
||||
|
||||
}).then(async (response) => {
|
||||
|
||||
const answer = response.choices[0].message.content;
|
||||
const usage = response.usage;
|
||||
|
||||
if (answer.length <= 4096) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.MainColor)
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: message.author.displayAvatarURL()
|
||||
})
|
||||
.setDescription(answer)
|
||||
.setFooter({
|
||||
text: `Costs ${func.pricing('gpt-3.5', usage.total_tokens)}`,
|
||||
iconURL: client.user.displayAvatarURL()
|
||||
});
|
||||
|
||||
await message.reply({ embeds: [embed] });
|
||||
|
||||
} else {
|
||||
|
||||
const attachment = new Discord.AttachmentBuilder(
|
||||
Buffer.from(`${question}\n\n${answer}`, 'utf-8'),
|
||||
{ name: 'response.txt' }
|
||||
);
|
||||
|
||||
await message.reply({ files: [attachment] });
|
||||
|
||||
};
|
||||
|
||||
}).catch(async (error) => {
|
||||
|
||||
console.error(chalk.bold.redBright(error));
|
||||
|
||||
if (error.response) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.ErrorColor)
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: message.author.displayAvatarURL()
|
||||
})
|
||||
.setDescription(error.response.error.message.length > 4096 ? error.response.error.message.substring(0, 4093) + "..." : error.response.error.message);
|
||||
|
||||
await message.reply({ embeds: [embed] }).catch(() => null);
|
||||
|
||||
} else if (error.message) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.ErrorColor)
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: message.author.displayAvatarURL()
|
||||
})
|
||||
.setDescription(error.message.length > 4096 ? error.message.substring(0, 4093) + "..." : error.message);
|
||||
|
||||
await message.reply({ embeds: [embed] }).catch(() => null);
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
},
|
||||
|
||||
};
|
124
commands/messages/ask-gpt 4.js
Normal file
124
commands/messages/ask-gpt 4.js
Normal file
|
@ -0,0 +1,124 @@
|
|||
const Discord = require('discord.js');
|
||||
const openAI = require('openai');
|
||||
const chalk = require('chalk');
|
||||
const fs = require('node:fs');
|
||||
const func = require('../../utils/functions');
|
||||
const settings = require('../../utils/settings');
|
||||
const config = require('../../configs/config.json');
|
||||
|
||||
module.exports = {
|
||||
name: "Ask2",
|
||||
aliases: ['A2', 'GPT4', 'GPT-4'],
|
||||
description: "Answers your questions using __GPT-4__ model! **(Smarter)**",
|
||||
|
||||
async execute(client, message, args, cmd) {
|
||||
|
||||
await message.channel.sendTyping();
|
||||
|
||||
if (!args[0]) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.ErrorColor)
|
||||
.setTitle('Error')
|
||||
.setDescription(`You can't use the \`${cmd}\` command like this you have to provide something like the example\n\`\`\`\n${config.Prefix}${cmd} Explain loops in JavaScript.\n\`\`\``);
|
||||
|
||||
await message.reply({ embeds: [embed] });
|
||||
|
||||
} else {
|
||||
|
||||
const openai = new openAI.OpenAI({ apiKey: config.OpenAIapiKey });
|
||||
|
||||
const question = args.join(" ");
|
||||
|
||||
const completionPrompt = fs.readFileSync("./utils/prompts/completion.txt", "utf-8");
|
||||
const prompt = completionPrompt.replaceAll('{botUsername}', client.user.username);
|
||||
const messages = [
|
||||
{
|
||||
"role": "system",
|
||||
"content": prompt
|
||||
},
|
||||
{
|
||||
"role": 'user',
|
||||
"content": question
|
||||
}
|
||||
];
|
||||
|
||||
openai.chat.completions.create({
|
||||
|
||||
model: 'gpt-4',
|
||||
messages: messages,
|
||||
max_tokens: func.tokenizer('gpt-4', messages).maxTokens,
|
||||
temperature: settings.completion.temprature,
|
||||
top_p: settings.completion.top_p,
|
||||
frequency_penalty: settings.completion.frequency_penalty,
|
||||
presence_penalty: settings.completion.presence_penalty
|
||||
|
||||
}).then(async (response) => {
|
||||
|
||||
const answer = response.choices[0].message.content;
|
||||
const usage = response.usage;
|
||||
|
||||
if (answer.length <= 4096) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.MainColor)
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: message.author.displayAvatarURL()
|
||||
})
|
||||
.setDescription(answer)
|
||||
.setFooter({
|
||||
text: `Costs ${func.pricing('gpt-4', usage.total_tokens)}`,
|
||||
iconURL: client.user.displayAvatarURL()
|
||||
});
|
||||
|
||||
await message.reply({ embeds: [embed] });
|
||||
|
||||
} else {
|
||||
|
||||
const attachment = new Discord.AttachmentBuilder(
|
||||
Buffer.from(`${question}\n\n${answer}`, 'utf-8'),
|
||||
{ name: 'response.txt' }
|
||||
);
|
||||
|
||||
await message.reply({ files: [attachment] });
|
||||
|
||||
};
|
||||
|
||||
}).catch(async (error) => {
|
||||
|
||||
console.error(chalk.bold.redBright(error));
|
||||
|
||||
if (error.response) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.ErrorColor)
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: message.author.displayAvatarURL()
|
||||
})
|
||||
.setDescription(error.response.error.message.length > 4096 ? error.response.error.message.substring(0, 4093) + "..." : error.response.error.message);
|
||||
|
||||
await message.reply({ embeds: [embed] }).catch(() => null);
|
||||
|
||||
} else if (error.message) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.ErrorColor)
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: message.author.displayAvatarURL()
|
||||
})
|
||||
.setDescription(error.message.length > 4096 ? error.message.substring(0, 4093) + "..." : error.message);
|
||||
|
||||
await message.reply({ embeds: [embed] }).catch(() => null);
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
},
|
||||
|
||||
};
|
37
commands/messages/feedback.js
Normal file
37
commands/messages/feedback.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
const { EmbedBuilder } = require('discord.js');
|
||||
|
||||
module.exports = {
|
||||
name: "feedback",
|
||||
aliases: ["suggest", "improve"],
|
||||
description: "Provide feedback or suggestions to improve the bot.",
|
||||
|
||||
async execute(client, message, args, cmd) {
|
||||
// Check if content is provided for the feedback
|
||||
if (!args.length) {
|
||||
return message.reply("Please provide your feedback or suggestion.");
|
||||
}
|
||||
|
||||
const feedbackChannelId = "1213062524526927892"; // Hardcoded channel ID where feedback will be sent
|
||||
|
||||
const feedbackChannel = client.channels.cache.get(feedbackChannelId);
|
||||
|
||||
if (!feedbackChannel) {
|
||||
return message.reply("The feedback channel is not configured or I couldn't find it.");
|
||||
}
|
||||
|
||||
// Construct the embed for the feedback
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor("#00ff00") // Change color if needed
|
||||
.setTitle("New Feedback/Suggestion")
|
||||
.setDescription(args.join(" "))
|
||||
.setTimestamp()
|
||||
|
||||
try {
|
||||
await feedbackChannel.send({ embeds: [embed] });
|
||||
message.reply("Your feedback/suggestion has been submitted successfully! Thank you for helping us improve the bot.");
|
||||
} catch (error) {
|
||||
console.error("Error sending feedback:", error);
|
||||
message.reply("There was an error submitting your feedback/suggestion. Please try again later.");
|
||||
}
|
||||
}
|
||||
};
|
33
commands/messages/help.js
Normal file
33
commands/messages/help.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
const Discord = require('discord.js');
|
||||
const config = require('../../configs/config.json');
|
||||
const { chatbot } = require('../../configs/chatbot');
|
||||
|
||||
module.exports = {
|
||||
name: "Help",
|
||||
aliases: ["H", "CMD", "CMDs", "Command", "Commands"],
|
||||
description: "Shows This!",
|
||||
|
||||
async execute(client, message, args, cmd) {
|
||||
|
||||
await message.channel.sendTyping();
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.MainColor)
|
||||
.setAuthor({
|
||||
name: `${client.user.username} Commands`,
|
||||
iconURL: client.user.displayAvatarURL({ size: 1024 })
|
||||
})
|
||||
.setDescription(client.MessageCommands.map(c => `> \`${config.Prefix}${c.name}\` \`(${c.aliases?.map(a => `${config.Prefix}${a}`)?.join(' / ') || 'No Aliases'})\`\n> *${c.description}*`).join('\n\n'))
|
||||
.setFooter({ text: 'Assisto' });
|
||||
|
||||
if (chatbot.State) embed.addFields({
|
||||
name: 'ChatBot:',
|
||||
value: `Channel: <#${chatbot.ChatBotChannel}>`,
|
||||
inline: true
|
||||
});
|
||||
|
||||
await message.reply({ embeds: [embed] });
|
||||
|
||||
},
|
||||
|
||||
};
|
125
commands/messages/imagine.js
Normal file
125
commands/messages/imagine.js
Normal file
|
@ -0,0 +1,125 @@
|
|||
const Discord = require('discord.js');
|
||||
const openAI = require('openai');
|
||||
const chalk = require('chalk');
|
||||
const func = require('../../utils/functions');
|
||||
const config = require('../../configs/config.json');
|
||||
|
||||
module.exports = {
|
||||
name: "Imagine",
|
||||
aliases: ['I', 'D', 'Draw'],
|
||||
description: "Draw your imaginations!",
|
||||
|
||||
async execute(client, message, args, cmd) {
|
||||
|
||||
await message.channel.sendTyping();
|
||||
|
||||
if (!args[0]) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.ErrorColor)
|
||||
.setTitle('Error')
|
||||
.setDescription(`You can't use the \`${cmd}\` command like this you have to provide something like the example\n\`\`\`\n${config.Prefix}${cmd} A Dragon under water\n\`\`\``);
|
||||
|
||||
await message.reply({ embeds: [embed] });
|
||||
|
||||
};
|
||||
|
||||
const openai = new openAI.OpenAI({ apiKey: config.OpenAIapiKey });
|
||||
|
||||
const question = args.join(" ");
|
||||
|
||||
openai.images.generate({
|
||||
|
||||
prompt: question,
|
||||
n: 4,
|
||||
size: '1024x1024'
|
||||
|
||||
}).then(async (response) => {
|
||||
|
||||
const data = response.data;
|
||||
|
||||
const embeds = [
|
||||
|
||||
new Discord.EmbedBuilder()
|
||||
.setColor(config.MainColor)
|
||||
.setURL('')
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: message.author.displayAvatarURL()
|
||||
})
|
||||
.setImage(data[0].url)
|
||||
.setFooter({
|
||||
text: `Costs ${func.pricing('dall.e', 4, '1024x1024')}`,
|
||||
iconURL: client.user.displayAvatarURL()
|
||||
})
|
||||
|
||||
];
|
||||
|
||||
const buttons = [
|
||||
|
||||
new Discord.ButtonBuilder()
|
||||
.setStyle(Discord.ButtonStyle.Link)
|
||||
.setLabel('Image 1')
|
||||
.setURL(data[0].url)
|
||||
|
||||
];
|
||||
|
||||
for (let i = 0; i < 3; i++) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setURL('')
|
||||
.setImage(data[i + 1].url);
|
||||
|
||||
const button = new Discord.ButtonBuilder()
|
||||
.setStyle(Discord.ButtonStyle.Link)
|
||||
.setLabel(`Image ${i + 2}`)
|
||||
.setURL(data[i + 1].url)
|
||||
|
||||
embeds.push(embed);
|
||||
buttons.push(button);
|
||||
|
||||
};
|
||||
|
||||
const row = new Discord.ActionRowBuilder()
|
||||
.addComponents(buttons);
|
||||
|
||||
await message.reply({
|
||||
embeds: embeds,
|
||||
components: [row]
|
||||
});
|
||||
|
||||
}).catch(async (error) => {
|
||||
|
||||
console.error(chalk.bold.redBright(error));
|
||||
|
||||
if (error.response) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.ErrorColor)
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: message.author.displayAvatarURL()
|
||||
})
|
||||
.setDescription(error.response.error.message.length > 4096 ? error.response.error.message.substring(0, 4093) + "..." : error.response.error.message);
|
||||
|
||||
await message.reply({ embeds: [embed] }).catch(() => null);
|
||||
|
||||
} else if (error.message) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.ErrorColor)
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: message.author.displayAvatarURL()
|
||||
})
|
||||
.setDescription(error.message.length > 4096 ? error.message.substring(0, 4093) + "..." : error.message);
|
||||
|
||||
await message.reply({ embeds: [embed] }).catch(() => null);
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
};
|
40
commands/messages/log.js
Normal file
40
commands/messages/log.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
const Discord = require('discord.js');
|
||||
const config = require('../../configs/config.json');
|
||||
const { Client, EmbedBuilder } = require('discord.js');
|
||||
|
||||
module.exports = {
|
||||
name: "Log",
|
||||
aliases: ["L", "LogMessage"],
|
||||
description: "Send an embed message to the log channel",
|
||||
|
||||
async execute(client, message, args, cmd) {
|
||||
if (!args.length) {
|
||||
return message.reply("Please provide content for the log message.");
|
||||
}
|
||||
|
||||
const logChannelId = "1152127763214516284"; // Hardcoded Log Channel ID
|
||||
|
||||
const logChannel = client.channels.cache.get(logChannelId);
|
||||
|
||||
if (!logChannel) {
|
||||
return message.reply("I couldn't find the log channel. Please make sure it's configured correctly.");
|
||||
}
|
||||
|
||||
// Check if the bot has permissions to send messages to the log channel
|
||||
if (!logChannel.permissionsFor(client.user).has('SEND_MESSAGES')) {
|
||||
return message.reply("I don't have permission to send messages to the log channel.");
|
||||
}
|
||||
|
||||
// Construct the embed using MessageEmbed constructor
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(args.join(" "));
|
||||
|
||||
try {
|
||||
await logChannel.send({ embeds: [embed] });
|
||||
message.reply("Embed message sent to the log channel successfully!");
|
||||
} catch (error) {
|
||||
console.error("Error sending message:", error);
|
||||
message.reply("There was an error sending the message to the log channel.");
|
||||
}
|
||||
}
|
||||
};
|
111
commands/messages/optimize.js
Normal file
111
commands/messages/optimize.js
Normal file
|
@ -0,0 +1,111 @@
|
|||
const Discord = require('discord.js');
|
||||
const openAI = require('openai');
|
||||
const chalk = require('chalk');
|
||||
const fs = require('node:fs');
|
||||
const func = require('../../utils/functions');
|
||||
const settings = require('../../utils/settings');
|
||||
const config = require('../../configs/config.json');
|
||||
|
||||
module.exports = {
|
||||
name: "Optimize",
|
||||
aliases: ['O', 'OPT', 'Fix'],
|
||||
description: "Optimizes your imaginations to get better response with draw!",
|
||||
|
||||
async execute(client, message, args, cmd) {
|
||||
|
||||
await message.channel.sendTyping();
|
||||
|
||||
if (!args[0]) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.ErrorColor)
|
||||
.setTitle('Error')
|
||||
.setDescription(`You can't use the \`${cmd}\` command like this you have to provide something like the example\n\`\`\`\n${config.Prefix}${cmd} A Dragon under water\n\`\`\``);
|
||||
|
||||
await message.reply({ embeds: [embed] });
|
||||
|
||||
};
|
||||
|
||||
const openai = new openAI.OpenAI({ apiKey: config.OpenAIapiKey });
|
||||
|
||||
const question = args.join(" ");
|
||||
|
||||
const optimizerPrompt = fs.readFileSync("./utils/prompts/optimizer.txt", "utf-8");
|
||||
const prompt = optimizerPrompt + question + ".";
|
||||
|
||||
const messages = [{
|
||||
"role": 'user',
|
||||
"content": prompt
|
||||
}];
|
||||
|
||||
openai.chat.completions.create({
|
||||
|
||||
model: 'gpt-3.5-turbo',
|
||||
messages: messages,
|
||||
max_tokens: func.tokenizer('gpt-3.5', messages).maxTokens,
|
||||
temperature: settings.optimzer.temprature,
|
||||
top_p: settings.optimzer.top_p,
|
||||
frequency_penalty: settings.optimzer.frequency_penalty,
|
||||
presence_penalty: settings.optimzer.presence_penalty
|
||||
|
||||
}).then(async (response) => {
|
||||
|
||||
const answer = response.choices[0].message.content
|
||||
.replace("Optimized Prompt:", "")
|
||||
.replace("Optimized prompt:", "")
|
||||
.replace("Optimized Output:", "")
|
||||
.replace("Optimized output:", "")
|
||||
.replace("Output:", "")
|
||||
.replace("output:", "");
|
||||
|
||||
const usage = response.usage;
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.MainColor)
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: message.author.displayAvatarURL()
|
||||
})
|
||||
.setDescription(answer)
|
||||
.setFooter({
|
||||
text: `Costs ${func.pricing('gpt-3.5', usage.total_tokens)}`,
|
||||
iconURL: client.user.displayAvatarURL()
|
||||
});
|
||||
|
||||
await message.reply({ embeds: [embed] });
|
||||
|
||||
}).catch(async (error) => {
|
||||
|
||||
console.error(chalk.bold.redBright(error));
|
||||
|
||||
if (error.response) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.ErrorColor)
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: message.author.displayAvatarURL()
|
||||
})
|
||||
.setDescription(error.response.error.message.length > 4096 ? error.response.error.message.substring(0, 4093) + "..." : error.response.error.message);
|
||||
|
||||
await message.reply({ embeds: [embed] }).catch(() => null);
|
||||
|
||||
} else if (error.message) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.ErrorColor)
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: message.author.displayAvatarURL()
|
||||
})
|
||||
.setDescription(error.message.length > 4096 ? error.message.substring(0, 4093) + "..." : error.message);
|
||||
|
||||
await message.reply({ embeds: [embed] }).catch(() => null);
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
};
|
47
commands/messages/ping.js
Normal file
47
commands/messages/ping.js
Normal file
|
@ -0,0 +1,47 @@
|
|||
const Discord = require('discord.js');
|
||||
const os = require('node:os');
|
||||
const func = require('../../utils/functions');
|
||||
const config = require('../../configs/config.json');
|
||||
|
||||
module.exports = {
|
||||
name: "Ping",
|
||||
aliases: ["P", "L", "Latency"],
|
||||
description: "Shows the bot\'s latency.",
|
||||
|
||||
async execute(client, message, args, cmd) {
|
||||
|
||||
await message.channel.sendTyping();
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.MainColor)
|
||||
.setAuthor({
|
||||
name: `Pong!`,
|
||||
iconURL: client.user.displayAvatarURL({ size: 1024 })
|
||||
})
|
||||
.addFields(
|
||||
{
|
||||
name: `📡 Ping:`,
|
||||
value: `${client.ws.ping}ms`,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: `💾 Memory:`,
|
||||
value: `${func.numberWithCommas(Math.round((process.memoryUsage().rss / 1024 / 1024)))}/${func.numberWithCommas(Math.round(os.totalmem() / 1024 / 1024))}MB`,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: `⏳ Uptime:`,
|
||||
value: func.timestamp(client.readyTimestamp),
|
||||
inline: false
|
||||
},
|
||||
)
|
||||
.setFooter({
|
||||
text: `Commanded by ${message.author.tag}`,
|
||||
iconURL: message.author.displayAvatarURL({ size: 1024 })
|
||||
});
|
||||
|
||||
await message.reply({ embeds: [embed] });
|
||||
|
||||
},
|
||||
|
||||
};
|
126
commands/messages/translate.js
Normal file
126
commands/messages/translate.js
Normal file
|
@ -0,0 +1,126 @@
|
|||
const Discord = require('discord.js');
|
||||
const openAI = require('openai');
|
||||
const chalk = require('chalk');
|
||||
const fs = require('node:fs');
|
||||
const func = require('../../utils/functions');
|
||||
const settings = require('../../utils/settings');
|
||||
const config = require('../../configs/config.json');
|
||||
|
||||
module.exports = {
|
||||
name: "Translate",
|
||||
aliases: ['T'],
|
||||
description: "Translate your texts from any language to English!",
|
||||
|
||||
async execute(client, message, args, cmd) {
|
||||
|
||||
await message.channel.sendTyping();
|
||||
|
||||
if (!args[0]) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.ErrorColor)
|
||||
.setTitle('Error')
|
||||
.setDescription(`You can't use the \`${cmd}\` command like this you have to provide something like the example\n\`\`\`\n${config.Prefix}${cmd} Salut bonne matinée
|
||||
.\n\`\`\``);
|
||||
|
||||
await message.reply({ embeds: [embed] });
|
||||
|
||||
} else {
|
||||
|
||||
const openai = new openAI.OpenAI({ apiKey: config.OpenAIapiKey });
|
||||
|
||||
const question = args.join(" ");
|
||||
|
||||
const language = 'English';
|
||||
const translatorPrompt = fs.readFileSync("./utils/prompts/translator.txt", "utf-8")
|
||||
const prompt = translatorPrompt.replaceAll('{language}', language);
|
||||
|
||||
const messages = [
|
||||
{
|
||||
"role": "system",
|
||||
"content": prompt
|
||||
},
|
||||
{
|
||||
"role": 'user',
|
||||
"content": question
|
||||
}
|
||||
];
|
||||
|
||||
openai.chat.completions.create({
|
||||
|
||||
model: 'gpt-3.5-turbo',
|
||||
messages: messages,
|
||||
max_tokens: func.tokenizer('gpt-3.5', messages).maxTokens,
|
||||
temperature: settings.translator.temprature,
|
||||
top_p: settings.translator.top_p,
|
||||
frequency_penalty: settings.translator.frequency_penalty,
|
||||
presence_penalty: settings.translator.presence_penalty
|
||||
|
||||
}).then(async (response) => {
|
||||
|
||||
const answer = response.choices[0].message.content;
|
||||
const usage = response.usage;
|
||||
|
||||
if (answer.length <= 4096) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.MainColor)
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: message.author.displayAvatarURL()
|
||||
})
|
||||
.setDescription(answer)
|
||||
.setFooter({
|
||||
text: `Costs ${func.pricing('gpt-3.5', usage.total_tokens)}`,
|
||||
iconURL: client.user.displayAvatarURL()
|
||||
});
|
||||
|
||||
await message.reply({ embeds: [embed] });
|
||||
|
||||
} else {
|
||||
|
||||
const attachment = new Discord.AttachmentBuilder(
|
||||
Buffer.from(`${question}\n\n${answer}`, 'utf-8'),
|
||||
{ name: 'response.txt' }
|
||||
);
|
||||
await message.reply({ files: [attachment] });
|
||||
|
||||
};
|
||||
|
||||
}).catch(async (error) => {
|
||||
|
||||
console.error(chalk.bold.redBright(error));
|
||||
|
||||
if (error.response) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.ErrorColor)
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: message.author.displayAvatarURL()
|
||||
})
|
||||
.setDescription(error.response.error.message.length > 4096 ? error.response.error.message.substring(0, 4093) + "..." : error.response.error.message);
|
||||
|
||||
await message.reply({ embeds: [embed] }).catch(() => null);
|
||||
|
||||
} else if (error.message) {
|
||||
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setColor(config.ErrorColor)
|
||||
.setAuthor({
|
||||
name: question.length > 256 ? question.substring(0, 253) + "..." : question,
|
||||
iconURL: message.author.displayAvatarURL()
|
||||
})
|
||||
.setDescription(error.message.length > 4096 ? error.message.substring(0, 4093) + "..." : error.message);
|
||||
|
||||
await message.reply({ embeds: [embed] }).catch(() => null);
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
},
|
||||
|
||||
};
|
18
configs/chatbot.js
Normal file
18
configs/chatbot.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
module.exports.chatbot = {
|
||||
// true: Enable the chatbot model.
|
||||
// false: Disable the chatbot model.
|
||||
State: true,
|
||||
// ChatBot's channel ID. It could be a text, announcement, voice, thread or post channel ID.
|
||||
AllowedChannels: ["assisto", "assisto2"],
|
||||
// A list of user IDs that the bot ignores messages from them.
|
||||
IgnoredUsers: [
|
||||
"1199858077655126188",
|
||||
"1111111111111111111",
|
||||
"2222222222222222222"
|
||||
],
|
||||
|
||||
// true: Enable the chatbot to reply in DMs.
|
||||
// false: Disable the chatbot from replying in DMs.
|
||||
ReplyInDMs: true
|
||||
|
||||
};
|
8
configs/config.json
Normal file
8
configs/config.json
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"Prefix": "-",
|
||||
"MainColor": "#5DE4EF",
|
||||
"ErrorColor": "#F12215",
|
||||
"ClientID": "1092982783191822336",
|
||||
"Token": "MTE5OTg1ODA3NzY1NTEyNjE4OA.Gx7dL8.0hC22mfq2KiOX1KI0rgn7HdNIgThr00izBbIvw",
|
||||
"OpenAIapiKey": "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"
|
||||
}
|
79
configs/moderation.js
Normal file
79
configs/moderation.js
Normal file
|
@ -0,0 +1,79 @@
|
|||
module.exports.moderation = {
|
||||
// true: Enable the Moderation model.
|
||||
// false: Disable the Moderation model.
|
||||
State: true,
|
||||
// A list of channel IDs that the bot ignores messages from.
|
||||
IgnoredChannels: [
|
||||
"0000000000000000000",
|
||||
"1111111111111111111",
|
||||
"2222222222222222222"
|
||||
],
|
||||
// A list of user IDs that the bot ignores messages from.
|
||||
IgnoredUsers: [
|
||||
"0000000000000000000",
|
||||
"1111111111111111111",
|
||||
"2222222222222222222"
|
||||
],
|
||||
// Log's channel ID. It could be a text, announcement, voice, thread or post channel ID.
|
||||
LogChannel: "1152127763214516284",
|
||||
// Log's embed color. It could be a #HexCode or resolvable text like: "Red", "Blue", "Purple", "Green", "Yellow"
|
||||
LogColor: "Red",
|
||||
// A list of roles that can use moderation buttons without having permissions.
|
||||
AdminRoles: [
|
||||
"1092989604551987230",
|
||||
"1111111111111111111",
|
||||
"2222222222222222222"
|
||||
],
|
||||
// A list of users that can use moderation buttons without having permissions.
|
||||
AdminUsers: [
|
||||
"1092059992804307075",
|
||||
"1111111111111111111",
|
||||
"2222222222222222222"
|
||||
],
|
||||
// true: Deletes Flagged Messages automatically.
|
||||
// false: Doesn't delete flagged messages automatically.
|
||||
AutoDelete: {
|
||||
"Sexual": true,
|
||||
"Hate": true,
|
||||
"Harassment": true,
|
||||
"Self-Harm": true,
|
||||
"Violence": true
|
||||
},
|
||||
// true: Punishes flagged messages' authors automatically.
|
||||
// false: Doesn't punish flagged messages' authors automatically.
|
||||
AutoPunish: {
|
||||
"Sexual": false,
|
||||
"Hate": false,
|
||||
"Harassment": false,
|
||||
"Self-Harm": false,
|
||||
"Violence": false
|
||||
},
|
||||
// Valid punishment types for flagged messages' authors if "AutoPunish" is enabled: "Timeout", "Kick", "Ban"
|
||||
// Note: If more than 1 flag is enabled, the priority will be as follows: 1. Ban 2. Kick. 3. Timeout.
|
||||
AutoPunishType: {
|
||||
"Sexual": "Timeout",
|
||||
"Hate": "Timeout",
|
||||
"Harassment": "Timeout",
|
||||
"Self-Harm": "Timeout",
|
||||
"Violence": "Timeout"
|
||||
},
|
||||
// For timeouts it will be the timeout's duration.
|
||||
// For bans, it will be the number of days from which it will purge the message history.
|
||||
// For kick it doesn't do anything.
|
||||
// Valid timeout duration: 1 Minute - 28 Days
|
||||
// Valid ban delete messages duration: 0 Seconds - 7 Days
|
||||
// Note: If more than 1 flag is enabled, it'll check for the longest duration.
|
||||
// Eexamples:
|
||||
// Second: 1s / 10sec / 30secs / 60second / 120seconds
|
||||
// Minute: 1m / 10min / 30mins / 60minute / 120minutes
|
||||
// Hour: 1h / 2hr / 3hrs / 4hour / 5hours
|
||||
// Day: 1d / 2day / 3days
|
||||
// Week: 1w / 2week / 3weeks
|
||||
AutoPunishDuration: {
|
||||
"Sexual": "1d",
|
||||
"Hate": "1d",
|
||||
"Harassment": "1d",
|
||||
"Self-Harm": "1d",
|
||||
"Violence": "1d"
|
||||
},
|
||||
};
|
26
conversations.json
Normal file
26
conversations.json
Normal file
|
@ -0,0 +1,26 @@
|
|||
{"user":"1092059992804307075","userMessage":"hello","botResponse":"Hey there! Welcome to Shadow ~ Hosting! How can I assist you today? 😄\n\nI heard a rumor that a new store is opening in town."}
|
||||
{"user":"1092059992804307075","userMessage":"where is node 4","botResponse":"Hey there! It seems like you're looking for Node 4. If you're referring to Node.js version 4, it's pretty old and not recommended for use due to security and compatibility issues. The latest stable version is Node.js 16, which offers better performance and security features. If you need help installing Node.js on your server, feel free to ask! 🚀"}
|
||||
{"user":"1092059992804307075","userMessage":"Where are our nodes located","botResponse":"Our servers are strategically located in data centers across various regions to ensure optimal performance and reliability. We have nodes in multiple locations, including but not limited to the USA, Europe, and Asia. This diverse network allows us to offer low latency and high availability for our hosting services. If you have specific location requirements or need more details about our server locations, feel free to ask! 🌍🔒"}
|
||||
{"user":"1092059992804307075","userMessage":"can you give me basic code for a Discord.js v14 starter bot?","botResponse":"Absolutely! Here's a simple example of code to get you started with a Discord.js v14 bot:\n\n```javascript\nconst { Client, Intents } = require('discord.js');\n\nconst client = new Client({ \n intents: [\n Intents.FLAGS.GUILDS,\n Intents.FLAGS.GUILD_MESSAGES\n ]\n});\n\nclient.on('ready', () => {\n console.log(`Logged in as ${client.user.tag}!`);\n});\n\nclient.on('messageCreate', message => {\n if (message.content === '!ping') {\n message.reply('Pong!');\n }\n});\n\nclient.login('YOUR_DISCORD_TOKEN_HERE');\n```\n\nMake sure to replace `'YOUR_DISCORD_TOKEN_HERE'` with your actual bot token obtained from the Discord Developer Portal. This basic bot responds with \"Pong!\" when it receives a `!ping` command. Feel free to customize and expand on this code for your bot's functionality! 🤖✨"}
|
||||
{"user":"1092059992804307075","userMessage":"make it more advanced?","botResponse":"Sure thing! Let's level up the bot with some additional features like a command handler and a more interactive response. Here's an enhanced version:\n\n```javascript\nconst { Client, Intents, Collection } = require('discord.js');\nconst fs = require('fs');\n\nconst client = new Client({ \n intents: [\n Intents.FLAGS.GUILDS,\n Intents.FLAGS.GUILD_MESSAGES\n ]\n});\n\nclient.commands = new Collection();\nconst commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));\n\nfor (const file of commandFiles) {\n const command = require(`./commands/${file}`);\n client.commands.set(command.data.name, command);\n}\n\nclient.on('ready', () => {\n console.log(`Logged in as ${client.user.tag}!`);\n});\n\nclient.on('messageCreate', message => {\n if (!message.content.startsWith('!') || message.author.bot) return;\n\n const args = message.content.slice('!'.length).trim().split(/ +/);\n const commandName = args.shift().toLowerCase();\n\n const command = client.commands.get(commandName);\n\n try {\n command.execute(message, args);\n } catch (error) {\n console.error(error);\n message.reply('There was an error trying to execute that command!');\n }\n});\n\nclient.login('YOUR_DISCORD_TOKEN_HERE');\n```\n\nIn this version, we implement a simple command handler to organize and execute different commands stored in separate files within a `commands` folder. Each command file exports an `execute` function to handle the specific functionality. Remember to create the `commands` folder and respective command files accordingly. Keep exploring and enhancing your bot's functionalities! 🚀🤖"}
|
||||
{"user":"1092059992804307075","userMessage":"what knowledge do you have?","botResponse":"Hey there! I'm your friendly AI assistant, {botUsername}, here to assist with all things related to Shadow ~ Hosting. My expertise lies in providing information and support regarding game servers, websites, custom and pre-made bots, virtual machines, affiliate programs, terms of service, privacy policies, and more offered by Shadow ~ Hosting.\n\nIf you have any questions or need help navigating through our hosting services, feel free to ask! Whether it's troubleshooting issues, exploring different hosting options, or seeking general advice on setting up your online presence, I'm here to lend a virtual hand. Let's chat and tackle any hosting challenges together! 🌐🎮🤖"}
|
||||
{"user":"1092059992804307075","userMessage":"What does Shadow ~ Hosting host?","botResponse":"Hey there! At Shadow ~ Hosting, we've got a diverse range of hosting services to cater to your needs. Here's a quick rundown of what we host:\n\n🎮 **Game Servers:** Dive into the gaming world with our game server hosting, perfect for creating a seamless multiplayer gaming experience.\n \n🌐 **Websites:** Establish your online presence with our website hosting services, ensuring your site runs smoothly and efficiently.\n\n🤖 **Custom & Pre-made Bots:** Need some specialized bot magic? We've got you covered with hosting solutions for custom and pre-made bots.\n\n💰 **Affiliate Program:** Join our affiliate program to earn rewards while spreading the word about Shadow ~ Hosting.\n\n✅ **Virtual Machines:** Explore our virtual machine hosting options for more flexibility and control over your server environment.\n\nRemember, if you have any specific questions or need assistance in choosing the right hosting service for your needs, feel free to reach out! We're here to make your hosting experience top-notch. 🚀🖥️"}
|
||||
{"user":"1092059992804307075","userMessage":"Node 4 is in the netherlands","botResponse":"Haha, love the humor! 🇳🇱 If Node 4 is in the Netherlands, then it sounds like we've got some hosting powerhouses over there ready to serve up some top-notch performance for our customers. Whether it's game servers, websites, or any other hosting needs, Node 4 in the Netherlands is geared up and good to go! Let's keep those virtual servers running smoothly and efficiently across the globe. 💪🌐"}
|
||||
{"user":"1092059992804307075","userMessage":"Where is Node 4","botResponse":"Ah, Node 4 is like that cool, mysterious friend who's always on the move! In our hosting world, Node 4 could be located in the Netherlands, as per your joke earlier. But hey, with our top-notch hosting services, you can rest assured that wherever Node 4 may roam, it's geared up to deliver excellent performance and reliability. So whether it's in the Netherlands or another exciting location in the hosting universe, Node 4 is ready to rock your server needs! 🚀🌍"}
|
||||
{"user":"1194616635059863594","userMessage":"Where is Node 4 located?","botResponse":"Hey there! 🌟 Node 4 isn't a physical location; it refers to the version of Node.js you're using for your server-side JavaScript applications. If you're looking to install or manage Node.js, you can do that within your hosting environment or on your local machine. Need any help with setting up Node.js or running into any issues? Just give me a shout! 😄👍"}
|
||||
{"user":"1194616635059863594","userMessage":"What was the last thing User 1092059992804307075 told you?","botResponse":"Oh, User 1092059992804307075? They were probably chatting about some hosting-related stuff or seeking assistance with their server setup. Unfortunately, I don't have the ability to recall specific user interactions like that. Is there anything else I can help you with today? 🤖🔍\n\nI heard a rumor that a new store is opening in town."}
|
||||
{"user":"1092059992804307075","userMessage":"<@1199858077655126188> Wake up","botResponse":"Hey <@1199858077655126188>, rise and shine! Looks like someone's calling you out to join the party. Time to jump into the convo and share those thoughts or questions. Let's keep the chat lively and engaging! 💬🎉"}
|
||||
{"user":"1092059992804307075","userMessage":"hey","botResponse":"Hey hey! What's up? Need any hosting help or just hanging out? 😄👋"}
|
||||
{"user":"1092059992804307075","userMessage":"What are you?","botResponse":"Hey there! I'm your friendly neighborhood AI assistant from Shadow ~ Hosting, here to help you with all your hosting needs. Game servers, websites, custom bots—you name it, I've got your back! 🤖💻 What can I assist you with today?"}
|
||||
{"user":"1092059992804307075","userMessage":"How many nodes do they have?","botResponse":"Hey hey! If you're talking about our servers, we offer 2 free servers per user. So you can get your game on or set up your website with a couple of sweet servers on us! 🎮🌐 Need any help setting them up or exploring more options? Just give me a shout! 👀🚀"}
|
||||
{"user":"1092059992804307075","userMessage":"hey","botResponse":"Hey hey! What's up? Need any hosting help or just here to chat? 🤖👋\n\nI stumbled upon a hidden gem of a restaurant yesterday."}
|
||||
{"user":"1092059992804307075","userMessage":"What nodes are there?","botResponse":"Hey, hey! We've got a few nodes in our network to serve you better:\n\n🌐 Node 1: Located in the Netherlands\n🌐 Node 2: Salt Lake City, US\n🌐 Node 4: Netherlands\n\nSadly, Node 3 is a bit MIA at the moment. Any specific location you're eyeing for your hosting needs? 🤔"}
|
||||
{"user":"1092059992804307075","userMessage":"Who is your provider?","botResponse":"Hey there! We partner up with Oxide Hosting for our services. They're the wizards behind the scenes! 🧙♂️ You can check them out at https://oxide.host for more insights. Need any recommendations or tips on getting started with them? Let me know!"}
|
||||
{"user":"1092059992804307075","userMessage":"Do you guys sell VPS?","botResponse":"You bet we do! We offer Virtual Private Servers tailored to your needs. Just let us know your desired specs like cores, RAM, and disk space, and we'll whip up a custom price for you. Our VPS are top-notch, based in Salt Lake City, US—quality all the way! Ready to dive into the world of VPS hosting? 🚀"}
|
||||
{"user":"1092059992804307075","userMessage":"Whats up with your Virtual Machines","botResponse":"Ah, Virtual Machines are our secret sauce for flexible hosting! We've got StarterVM, BoostVM, and EnhanceVM options. They come with root access, varying RAM sizes, disk space, and SSH access. Perfect for those who want more control over their hosting environment. Need help picking the right VM for your needs? Just give me a shout! 🤖"}
|
||||
{"user":"1092059992804307075","userMessage":"Do you do Websites?","botResponse":"Absolutely! We've got you covered with website hosting too. Whether it's a personal blog, business site, or an online portfolio, we've got the perfect plan for you. Our pricing is super competitive, starting at just $1 per month. Let's get your online presence up and running smoothly! 🌐"}
|
||||
{"user":"1092059992804307075","userMessage":"Who made you?","botResponse":"Oh, I'm the brainchild of ShadowVR, the genius behind Shadow ~ Hosting! He coded me in Javascript with Discord.js magic to be your trusty assistant here. So, if you've got questions or need help navigating the hosting world, I'm here to make your experience smooth as butter! 💻"}
|
||||
{"user":"1092059992804307075","userMessage":"What if what I'm looking for isn't offered by you?","botResponse":"If you're after something unique or a bit out of the box, no worries! Just hit me up with your specific requirements, and I can create a custom plan tailored just for you. Whether it's a special game server setup, a customized website hosting package, or even some bot wizardry, we can make it happen. Your wish is my command! ✨ Just let me know what you need!"}
|
||||
{"user":"1092059992804307075","userMessage":"I want a general VPS server with specs to run a AI LLM on it with no issues","botResponse":"Sounds like you need some serious power for that AI LLM! Let's craft a custom VPS plan to suit your needs perfectly. How about we go for something robust like this:\n\n```\nCustom VPS Plan:\n- 8 vCores\n- 32 GB RAM\n- 100 GB Disk\n- Unlimited Inbound and Outbound\n- 500 GB Traffic\n\nPrice: $50/mo 💸\n```\n\nWith these specs, your AI LLM should run like a dream without breaking a sweat! Solid performance and reliability all the way. What do you think? Ready to dive into the world of top-notch hosting for your AI project? Let me know! 🚀"}
|
||||
{"user":"1092059992804307075","userMessage":"lets say my range of pricing only reaches $10/mo","botResponse":"I totally get it, sticking to a budget is important! Let's dial down the specs while keeping things smooth for your AI LLM within your price range:\n\n```\nCustom VPS Plan:\n- 2 vCores\n- 4 GB RAM\n- 20 GB Disk\n- 100 GB Traffic\n\nPrice: $10/mo 💸\n```\n\nWith these specs, you'll still have a decent setup to run your AI LLM without any hiccups. It's all about finding that sweet spot between performance and affordability. Ready to kickstart your AI project on this tailored VPS plan? 🤖💻"}
|
||||
{"user":"1092059992804307075","userMessage":"Can I get it for cheaper or is that not allowed","botResponse":"Hey, I hear you on wanting to save those extra bucks! Let's tweak the custom VPS plan a bit more to fit your budget even better:\n\n```\nCustom VPS Plan:\n- 1 vCore\n- 2 GB RAM\n- 10 GB Disk\n- 50 GB Traffic\n\nPrice: $5/mo 💸\n```\n\nThis adjusted plan should help you stay within your desired price range while still providing a platform for your AI LLM. Sometimes, we gotta find that balance between cost and performance. Ready to kick off your AI project with this wallet-friendly setup? Let me know if it works for you! 🤖✨"}
|
0
eggactyl_config.yml
Normal file
0
eggactyl_config.yml
Normal file
674
events/interactionCreate.js
Normal file
674
events/interactionCreate.js
Normal file
|
@ -0,0 +1,674 @@
|
|||
const Discord = require('discord.js');
|
||||
const chalk = require('chalk');
|
||||
const ms = require('ms');
|
||||
const { moderation } = require('../configs/moderation');
|
||||
|
||||
module.exports = async (client, interaction) => {
|
||||
|
||||
try {
|
||||
|
||||
// Command Handler
|
||||
if (interaction.isChatInputCommand()) {
|
||||
|
||||
const command = client.SlashCommands.get(interaction.commandName);
|
||||
if (command) {
|
||||
|
||||
try {
|
||||
command.execute(client, interaction);
|
||||
} catch (error) {
|
||||
console.error(chalk.bold.redBright(error));
|
||||
return await interaction.reply({ content: error.message.length > 4096 ? error.message.slice(0, 4093) + "..." : error.message, ephemeral: true }).catch(() => null);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// Auto Moderation
|
||||
} else if (interaction.isButton()) {
|
||||
|
||||
const id = interaction.customId.split('-');
|
||||
|
||||
if (['deleteMessage', 'timeout', 'kick', 'ban'].includes(id[0])) {
|
||||
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
|
||||
let admin = false;
|
||||
if (
|
||||
interaction.member.roles.cache.hasAny(...moderation.AdminRoles)
|
||||
|| moderation.AdminUsers.includes(interaction.member.id)
|
||||
) admin = true;
|
||||
|
||||
|
||||
if (id[0] === 'deleteMessage') {
|
||||
|
||||
const channel = client.channels.cache.get(id[1]);
|
||||
if (admin || channel?.permissionsFor(interaction.member).has('ManageMessages')) {
|
||||
|
||||
if (channel.permissionsFor(interaction.guild.members.me).has('ManageMessages')) {
|
||||
|
||||
const message = await channel.messages.fetch({ message: id[2] }).catch(() => null);
|
||||
if (message) {
|
||||
|
||||
try {
|
||||
|
||||
await message.delete();
|
||||
|
||||
if (interaction.message.components.length === 1) {
|
||||
|
||||
const embed = Discord.EmbedBuilder.from(interaction.message.embeds[0]);
|
||||
|
||||
embed.addFields({
|
||||
name: 'Message Action:',
|
||||
value: `Message deleted by ${interaction.user} \`(${interaction.user.id})\``
|
||||
});
|
||||
|
||||
const row1 = Discord.ActionRowBuilder.from(interaction.message.components[0]);
|
||||
|
||||
const buttons = [];
|
||||
for (const button of interaction.message.components[1].components) {
|
||||
const newButton = Discord.ButtonBuilder.from(button).setDisabled();
|
||||
buttons.push(newButton);
|
||||
};
|
||||
|
||||
const row2 = new Discord.ActionRowBuilder()
|
||||
.addComponents(buttons);
|
||||
|
||||
await interaction.message.edit({
|
||||
embeds: [embed],
|
||||
components: [row1, row2]
|
||||
});
|
||||
|
||||
} else if (interaction.message.components.length > 1) {
|
||||
|
||||
const embed = Discord.EmbedBuilder.from(interaction.message.embeds[0]);
|
||||
|
||||
embed.addFields({
|
||||
name: 'Message Action:',
|
||||
value: `Message deleted by ${interaction.user} \`(${interaction.user.id})\``
|
||||
});
|
||||
|
||||
const row1 = Discord.ActionRowBuilder.from(interaction.message.components[0]);
|
||||
|
||||
const buttons = [];
|
||||
for (const button of interaction.message.components[1].components) {
|
||||
const newButton = Discord.ButtonBuilder.from(button).setDisabled();
|
||||
buttons.push(newButton);
|
||||
};
|
||||
|
||||
const row2 = new Discord.ActionRowBuilder()
|
||||
.addComponents(buttons);
|
||||
|
||||
await interaction.message.edit({
|
||||
embeds: [embed],
|
||||
components: [row1, row2]
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
await interaction.editReply({ content: 'The message has been deleted successfully.' });
|
||||
|
||||
} catch (error) {
|
||||
await interaction.editReply({ content: `There was an error while deleting this message, *(${error.message})*` });
|
||||
};
|
||||
|
||||
} else {
|
||||
|
||||
const row1 = Discord.ActionRowBuilder.from(interaction.message.components[0]);
|
||||
|
||||
const buttons = [];
|
||||
for (const button of interaction.message.components[1].components) {
|
||||
const newButton = Discord.ButtonBuilder.from(button).setDisabled();
|
||||
buttons.push(newButton);
|
||||
};
|
||||
|
||||
const row2 = new Discord.ActionRowBuilder()
|
||||
.addComponents(buttons);
|
||||
|
||||
await interaction.message.edit({ components: [row1, row2] });
|
||||
|
||||
await interaction.editReply({ content: 'This message has already been deleted.' });
|
||||
|
||||
};
|
||||
|
||||
} else await interaction.editReply({ content: `I need Manage Message permission in ${channel}.` });
|
||||
|
||||
} else await interaction.editReply({ content: 'You can\'t use this button. you are not an Admin.' });
|
||||
|
||||
} else if (id[0] === 'timeout') {
|
||||
|
||||
if (admin || interaction.member.permissions.has('ModerateMembers')) {
|
||||
|
||||
const member = await interaction.guild.members.fetch(id[1]).catch(() => null);
|
||||
if (member) {
|
||||
|
||||
try {
|
||||
|
||||
if (member.moderatable) {
|
||||
|
||||
if (
|
||||
interaction.member.roles.highest.comparePositionTo(member.roles.highest) <= 0
|
||||
&& interaction.user.id !== interaction.guild.ownerId
|
||||
) return await interaction.editReply({ content: `You can't timeout ${member.user.tag}` });
|
||||
|
||||
const timeoutButton1 = new Discord.ButtonBuilder()
|
||||
.setLabel(`60 Seconds`)
|
||||
.setStyle(Discord.ButtonStyle.Danger)
|
||||
.setCustomId('60s');
|
||||
const timeoutButton2 = new Discord.ButtonBuilder()
|
||||
.setLabel(`5 Mins`)
|
||||
.setStyle(Discord.ButtonStyle.Danger)
|
||||
.setCustomId('5m');
|
||||
const timeoutButton3 = new Discord.ButtonBuilder()
|
||||
.setLabel(`10 Mins`)
|
||||
.setStyle(Discord.ButtonStyle.Danger)
|
||||
.setCustomId('10m');
|
||||
const timeoutButton4 = new Discord.ButtonBuilder()
|
||||
.setLabel(`1 Hour`)
|
||||
.setStyle(Discord.ButtonStyle.Danger)
|
||||
.setCustomId('1h');
|
||||
const timeoutButton5 = new Discord.ButtonBuilder()
|
||||
.setLabel(`1 Day`)
|
||||
.setStyle(Discord.ButtonStyle.Danger)
|
||||
.setCustomId('1d');
|
||||
const timeoutButton6 = new Discord.ButtonBuilder()
|
||||
.setLabel(`3 Days`)
|
||||
.setStyle(Discord.ButtonStyle.Danger)
|
||||
.setCustomId('3d');
|
||||
const timeoutButton7 = new Discord.ButtonBuilder()
|
||||
.setLabel(`1 Week`)
|
||||
.setStyle(Discord.ButtonStyle.Danger)
|
||||
.setCustomId('1w');
|
||||
|
||||
const cancelButton = new Discord.ButtonBuilder()
|
||||
.setLabel(`Cancel`)
|
||||
.setStyle(Discord.ButtonStyle.Secondary)
|
||||
.setCustomId('Cancel');
|
||||
|
||||
const row1 = new Discord.ActionRowBuilder()
|
||||
.addComponents([
|
||||
timeoutButton1,
|
||||
timeoutButton2,
|
||||
timeoutButton3,
|
||||
timeoutButton4,
|
||||
]);
|
||||
|
||||
const row2 = new Discord.ActionRowBuilder()
|
||||
.addComponents([
|
||||
timeoutButton5,
|
||||
timeoutButton6,
|
||||
timeoutButton7,
|
||||
cancelButton,
|
||||
]);
|
||||
|
||||
const reply = await interaction.editReply({
|
||||
content: `Are you sure you want timeout ${member} (${member.user.tag}) if yes select one of the Timeout Durations buttons (Red ones)`,
|
||||
components: [
|
||||
row1,
|
||||
row2
|
||||
]
|
||||
});
|
||||
|
||||
const collector = await reply.createMessageComponentCollector({ time: 60000 });
|
||||
|
||||
collector.on('collect', async (int) => {
|
||||
|
||||
if (int.customId === 'Cancel') {
|
||||
|
||||
await collector.stop("messageDelete");
|
||||
await int.deferUpdate();
|
||||
await interaction.deleteReply();
|
||||
|
||||
} else {
|
||||
|
||||
await collector.stop("timed out");
|
||||
await int.deferUpdate();
|
||||
|
||||
const duration = ms(int.customId);
|
||||
await member.timeout(duration, `Timed out by ${interaction.user.tag}`);
|
||||
|
||||
const embed = Discord.EmbedBuilder.from(interaction.message.embeds[0]);
|
||||
|
||||
embed.addFields({
|
||||
name: 'Punish Action:',
|
||||
value: `${member.user.tag} timed out by ${interaction.user} \`(${interaction.user.id})\` for ${ms(duration, { long: true })}.`
|
||||
});
|
||||
|
||||
await interaction.message.edit({ embeds: [embed] }).catch(() => null);
|
||||
|
||||
await interaction.editReply({
|
||||
content: `${member.user.tag} has been timed out successfully.`,
|
||||
components: []
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
collector.on('end', async (collection, reason) => {
|
||||
|
||||
if (["messageDelete", "timed out"].includes(reason)) return;
|
||||
|
||||
await interaction.editReply({
|
||||
components: [
|
||||
new Discord.ActionRowBuilder().addComponents([
|
||||
timeoutButton1.setDisabled(true),
|
||||
timeoutButton2.setDisabled(true),
|
||||
timeoutButton3.setDisabled(true),
|
||||
timeoutButton4.setDisabled(true)
|
||||
]),
|
||||
new Discord.ActionRowBuilder().addComponents([
|
||||
timeoutButton5.setDisabled(true),
|
||||
timeoutButton6.setDisabled(true),
|
||||
timeoutButton7.setDisabled(true),
|
||||
cancelButton.setDisabled(true)
|
||||
]),
|
||||
]
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
} else await interaction.editReply({ content: `I can't timeout ${member.user.tag}.` });
|
||||
|
||||
} catch (error) {
|
||||
await interaction.editReply({ content: `There was an error while timeouting ${member}, *(${error.message})*` });
|
||||
};
|
||||
|
||||
} else {
|
||||
|
||||
const user = await client.users.fetch(id[1]).catch(() => null);
|
||||
if (user) await interaction.editReply({ content: `${user.tag} is no longer in the server.` });
|
||||
else await interaction.editReply({ content: 'This user is no longer in the server.' });
|
||||
|
||||
};
|
||||
|
||||
} else await interaction.editReply({ content: 'You can\'t use this button. you are not an Admin.' });
|
||||
|
||||
} else if (id[0] === 'kick') {
|
||||
|
||||
if (admin || interaction.member.permissions.has('KickMembers')) {
|
||||
|
||||
const member = await interaction.guild.members.fetch(id[1]).catch(() => null);
|
||||
if (member) {
|
||||
|
||||
try {
|
||||
|
||||
if (member.kickable) {
|
||||
|
||||
if (
|
||||
interaction.member.roles.highest.comparePositionTo(member.roles.highest) <= 0
|
||||
&& interaction.user.id !== interaction.guild.ownerId
|
||||
) return await interaction.editReply({ content: `You can't kick ${member.user.tag}` });
|
||||
|
||||
const kickButton = new Discord.ButtonBuilder()
|
||||
.setLabel(`Kick ${member.user.username}`)
|
||||
.setStyle(Discord.ButtonStyle.Danger)
|
||||
.setCustomId('Kick');
|
||||
|
||||
const cancelButton = new Discord.ButtonBuilder()
|
||||
.setLabel(`Cancel`)
|
||||
.setStyle(Discord.ButtonStyle.Secondary)
|
||||
.setCustomId('Cancel');
|
||||
|
||||
const row = new Discord.ActionRowBuilder()
|
||||
.addComponents([kickButton, cancelButton]);
|
||||
|
||||
const reply = await interaction.editReply({
|
||||
content: `Are you sure you want kick ${member} (${member.user.tag})`,
|
||||
components: [row]
|
||||
});
|
||||
|
||||
const collector = await reply.createMessageComponentCollector({ time: 60000 });
|
||||
|
||||
collector.on('collect', async (int) => {
|
||||
|
||||
if (int.customId === 'Kick') {
|
||||
|
||||
await collector.stop("kicked");
|
||||
await int.deferUpdate();
|
||||
|
||||
await member.kick(`Kicked by ${interaction.user.tag}`);
|
||||
|
||||
const embed = Discord.EmbedBuilder.from(interaction.message.embeds[0]);
|
||||
|
||||
embed.addFields({
|
||||
name: 'Punish Action:',
|
||||
value: `${member.user.tag} kicked by ${interaction.user} \`(${interaction.user.id})\``
|
||||
});
|
||||
|
||||
await interaction.message.edit({ embeds: [embed] }).catch(() => null);
|
||||
|
||||
await interaction.editReply({
|
||||
content: `${member.user.tag} has been kicked successfully.`,
|
||||
components: []
|
||||
});
|
||||
|
||||
} else if (int.customId === 'Cancel') {
|
||||
|
||||
await collector.stop("messageDelete");
|
||||
await int.deferUpdate();
|
||||
await interaction.deleteReply();
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
collector.on('end', async (collection, reason) => {
|
||||
|
||||
if (["messageDelete", "kicked"].includes(reason)) return;
|
||||
|
||||
await interaction.editReply({
|
||||
components: [new Discord.ActionRowBuilder().addComponents([
|
||||
kickButton.setDisabled(true),
|
||||
cancelButton.setDisabled(true)
|
||||
])]
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
} else await interaction.editReply({ content: `I can't kick ${member.user.tag}.` });
|
||||
|
||||
} catch (error) {
|
||||
await interaction.editReply({ content: `There was an error while kicking ${member}, *(${error.message})*` });
|
||||
};
|
||||
|
||||
} else {
|
||||
|
||||
const user = await client.users.fetch(id[1]).catch(() => null);
|
||||
if (user) await interaction.editReply({ content: `${user.tag} is no longer in the server.` });
|
||||
else await interaction.editReply({ content: 'This user is no longer in the server.' });
|
||||
|
||||
};
|
||||
|
||||
} else await interaction.editReply({ content: 'You can\'t use this button. you are not an Admin.' });
|
||||
|
||||
} else if (id[0] === 'ban') {
|
||||
|
||||
if (admin || interaction.member.permissions.has('BanMembers')) {
|
||||
|
||||
const member = await interaction.guild.members.fetch(id[1]).catch(() => null);
|
||||
if (member) {
|
||||
|
||||
try {
|
||||
|
||||
if (member.bannable) {
|
||||
|
||||
if (
|
||||
interaction.member.roles.highest.comparePositionTo(member.roles.highest) <= 0
|
||||
&& interaction.user.id !== interaction.guild.ownerId
|
||||
) return await interaction.editReply({ content: `You can't ban ${member.user.tag}` });
|
||||
|
||||
const banButton1 = new Discord.ButtonBuilder()
|
||||
.setLabel(`Don't Delete Any`)
|
||||
.setStyle(Discord.ButtonStyle.Danger)
|
||||
.setCustomId('0');
|
||||
const banButton2 = new Discord.ButtonBuilder()
|
||||
.setLabel(`Previous Hour`)
|
||||
.setStyle(Discord.ButtonStyle.Danger)
|
||||
.setCustomId('1h');
|
||||
const banButton3 = new Discord.ButtonBuilder()
|
||||
.setLabel(`Previous 6 Hours`)
|
||||
.setStyle(Discord.ButtonStyle.Danger)
|
||||
.setCustomId('6h');
|
||||
const banButton4 = new Discord.ButtonBuilder()
|
||||
.setLabel(`Previous 12 Hours`)
|
||||
.setStyle(Discord.ButtonStyle.Danger)
|
||||
.setCustomId('12h');
|
||||
const banButton5 = new Discord.ButtonBuilder()
|
||||
.setLabel(`Previous 24 Hours`)
|
||||
.setStyle(Discord.ButtonStyle.Danger)
|
||||
.setCustomId('24h');
|
||||
const banButton6 = new Discord.ButtonBuilder()
|
||||
.setLabel(`Previous 3 Days`)
|
||||
.setStyle(Discord.ButtonStyle.Danger)
|
||||
.setCustomId('3d');
|
||||
const banButton7 = new Discord.ButtonBuilder()
|
||||
.setLabel(`Previous 7 Days`)
|
||||
.setStyle(Discord.ButtonStyle.Danger)
|
||||
.setCustomId('7d');
|
||||
|
||||
const cancelButton = new Discord.ButtonBuilder()
|
||||
.setLabel(`Cancel`)
|
||||
.setStyle(Discord.ButtonStyle.Secondary)
|
||||
.setCustomId('Cancel');
|
||||
|
||||
const row1 = new Discord.ActionRowBuilder()
|
||||
.addComponents([
|
||||
banButton1,
|
||||
banButton2,
|
||||
banButton3,
|
||||
banButton4,
|
||||
]);
|
||||
|
||||
const row2 = new Discord.ActionRowBuilder()
|
||||
.addComponents([
|
||||
banButton5,
|
||||
banButton6,
|
||||
banButton7,
|
||||
cancelButton,
|
||||
]);
|
||||
|
||||
const reply = await interaction.editReply({
|
||||
content: `Are you sure you want ban ${member} (${member.user.tag}) if yes select one of the Delete Message History buttons (Red ones)`,
|
||||
components: [
|
||||
row1,
|
||||
row2
|
||||
]
|
||||
});
|
||||
|
||||
const collector = await reply.createMessageComponentCollector({ time: 60000 });
|
||||
|
||||
collector.on('collect', async (int) => {
|
||||
|
||||
if (int.customId === 'Cancel') {
|
||||
|
||||
await collector.stop("messageDelete");
|
||||
await int.deferUpdate();
|
||||
await interaction.deleteReply();
|
||||
|
||||
} else {
|
||||
|
||||
await collector.stop("banned");
|
||||
await int.deferUpdate();
|
||||
|
||||
const duration = ms(int.customId);
|
||||
await member.ban({ deleteMessageSeconds: duration / 1000, reason: `Banned by ${interaction.user.tag}` });
|
||||
|
||||
const embed = Discord.EmbedBuilder.from(interaction.message.embeds[0]);
|
||||
|
||||
let fieldValue = `${member.user.tag} banned by ${interaction.user} \`(${interaction.user.id})\` and all their messages in the last ${ms(duration, { long: true })} were deleted.`;
|
||||
if (duration === 0) fieldValue = `${member.user.tag} banned by ${interaction.user} \`(${interaction.user.id})\``;
|
||||
|
||||
embed.addFields({
|
||||
name: 'Punish Action:',
|
||||
value: fieldValue
|
||||
});
|
||||
|
||||
await interaction.message.edit({ embeds: [embed] }).catch(() => null);
|
||||
|
||||
await interaction.editReply({
|
||||
content: `${member.user.tag} has been banned successfully.`,
|
||||
components: []
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
collector.on('end', async (collection, reason) => {
|
||||
|
||||
if (["messageDelete", "banned"].includes(reason)) return;
|
||||
|
||||
await interaction.editReply({
|
||||
components: [
|
||||
new Discord.ActionRowBuilder().addComponents([
|
||||
banButton1.setDisabled(true),
|
||||
banButton2.setDisabled(true),
|
||||
banButton3.setDisabled(true),
|
||||
banButton4.setDisabled(true)
|
||||
]),
|
||||
new Discord.ActionRowBuilder().addComponents([
|
||||
banButton5.setDisabled(true),
|
||||
banButton6.setDisabled(true),
|
||||
banButton7.setDisabled(true),
|
||||
cancelButton.setDisabled(true)
|
||||
]),
|
||||
]
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
} else await interaction.editReply({ content: `I can't ban ${member.user.tag}.` });
|
||||
|
||||
} catch (error) {
|
||||
await interaction.editReply({ content: `There was an error while banning ${member}, *(${error.message})*` });
|
||||
};
|
||||
|
||||
} else {
|
||||
|
||||
const user = await client.users.fetch(id[1]).catch(() => null);
|
||||
|
||||
try {
|
||||
|
||||
const fetchedBan = await interaction.guild.bans.fetch(user.id).catch(() => null);
|
||||
if (!fetchedBan) {
|
||||
|
||||
const banButton1 = new Discord.ButtonBuilder()
|
||||
.setLabel(`Don't Delete Any`)
|
||||
.setStyle(Discord.ButtonStyle.Danger)
|
||||
.setCustomId('0');
|
||||
const banButton2 = new Discord.ButtonBuilder()
|
||||
.setLabel(`Previous Hour`)
|
||||
.setStyle(Discord.ButtonStyle.Danger)
|
||||
.setCustomId('1h');
|
||||
const banButton3 = new Discord.ButtonBuilder()
|
||||
.setLabel(`Previous 6 Hours`)
|
||||
.setStyle(Discord.ButtonStyle.Danger)
|
||||
.setCustomId('6h');
|
||||
const banButton4 = new Discord.ButtonBuilder()
|
||||
.setLabel(`Previous 12 Hours`)
|
||||
.setStyle(Discord.ButtonStyle.Danger)
|
||||
.setCustomId('12h');
|
||||
const banButton5 = new Discord.ButtonBuilder()
|
||||
.setLabel(`Previous 24 Hours`)
|
||||
.setStyle(Discord.ButtonStyle.Danger)
|
||||
.setCustomId('24h');
|
||||
const banButton6 = new Discord.ButtonBuilder()
|
||||
.setLabel(`Previous 3 Days`)
|
||||
.setStyle(Discord.ButtonStyle.Danger)
|
||||
.setCustomId('3d');
|
||||
const banButton7 = new Discord.ButtonBuilder()
|
||||
.setLabel(`Previous 7 Days`)
|
||||
.setStyle(Discord.ButtonStyle.Danger)
|
||||
.setCustomId('7d');
|
||||
|
||||
const cancelButton = new Discord.ButtonBuilder()
|
||||
.setLabel(`Cancel`)
|
||||
.setStyle(Discord.ButtonStyle.Secondary)
|
||||
.setCustomId('Cancel');
|
||||
|
||||
const row1 = new Discord.ActionRowBuilder()
|
||||
.addComponents([
|
||||
banButton1,
|
||||
banButton2,
|
||||
banButton3,
|
||||
banButton4,
|
||||
]);
|
||||
|
||||
const row2 = new Discord.ActionRowBuilder()
|
||||
.addComponents([
|
||||
banButton5,
|
||||
banButton6,
|
||||
banButton7,
|
||||
cancelButton,
|
||||
]);
|
||||
|
||||
const reply = await interaction.editReply({
|
||||
content: `Are you sure you want ban ${user} (${user.tag}) if yes select one of the Delete Message History buttons (Red ones)`,
|
||||
components: [
|
||||
row1,
|
||||
row2
|
||||
]
|
||||
});
|
||||
|
||||
const collector = await reply.createMessageComponentCollector({ time: 60000 });
|
||||
|
||||
collector.on('collect', async (int) => {
|
||||
|
||||
if (int.customId === 'Cancel') {
|
||||
|
||||
await collector.stop("messageDelete");
|
||||
await int.deferUpdate();
|
||||
await interaction.deleteReply();
|
||||
|
||||
} else {
|
||||
|
||||
await collector.stop("banned");
|
||||
await int.deferUpdate();
|
||||
|
||||
const duration = ms(int.customId);
|
||||
await interaction.guild.bans.create(id[1], { deleteMessageSeconds: duration / 1000, reason: `Banned by ${interaction.user.tag}` });
|
||||
|
||||
const embed = Discord.EmbedBuilder.from(interaction.message.embeds[0]);
|
||||
|
||||
let fieldValue = `${user ? user.tag : id[1]} banned by ${interaction.user} \`(${interaction.user.id})\` and all their messages in the last ${ms(duration, { long: true })} were deleted.`;
|
||||
if (duration === 0) fieldValue = `${user ? user.tag : id[1]} banned by ${interaction.user} \`(${interaction.user.id})\``;
|
||||
|
||||
embed.addFields({
|
||||
name: 'Punish Action:',
|
||||
value: fieldValue
|
||||
});
|
||||
|
||||
await interaction.message.edit({ embeds: [embed] }).catch(() => null);
|
||||
|
||||
await interaction.editReply({
|
||||
content: `${user ? user.tag : id[1]} has been banned successfully.`,
|
||||
components: []
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
collector.on('end', async (collection, reason) => {
|
||||
|
||||
if (["messageDelete", "banned"].includes(reason)) return;
|
||||
|
||||
await interaction.editReply({
|
||||
components: [
|
||||
new Discord.ActionRowBuilder().addComponents([
|
||||
banButton1.setDisabled(true),
|
||||
banButton2.setDisabled(true),
|
||||
banButton3.setDisabled(true),
|
||||
banButton4.setDisabled(true)
|
||||
]),
|
||||
new Discord.ActionRowBuilder().addComponents([
|
||||
banButton5.setDisabled(true),
|
||||
banButton6.setDisabled(true),
|
||||
banButton7.setDisabled(true),
|
||||
cancelButton.setDisabled(true)
|
||||
]),
|
||||
]
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
} else await interaction.editReply({ content: `${fetchedBan.user.tag} has been already banned.` });
|
||||
|
||||
} catch (error) {
|
||||
await interaction.editReply({ content: `There was an error while banning this user, *(${error.message})*` });
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
} else await interaction.editReply({ content: 'You can\'t use this button. you are not an Admin.' });
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
console.error(chalk.bold.redBright(error));
|
||||
};
|
||||
|
||||
};
|
467
events/messageCreate.js
Normal file
467
events/messageCreate.js
Normal file
|
@ -0,0 +1,467 @@
|
|||
const Discord = require('discord.js');
|
||||
const openAI = require('openai');
|
||||
const chalk = require('chalk');
|
||||
const ms = require('ms');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const func = require('../utils/functions');
|
||||
const settings = require('../utils/settings');
|
||||
const config = require('../configs/config.json');
|
||||
const { moderation } = require('../configs/moderation');
|
||||
const { chatbot } = require('../configs/chatbot');
|
||||
const conversations = new Map();
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
|
||||
// Load the knowledge from the completion.txt file
|
||||
const knowledge = fs.readFileSync(path.join(__dirname, '../utils/prompts/completion.txt'), 'utf-8');
|
||||
|
||||
// Load the conversation history from the conversations.json file
|
||||
let conversationHistory = [];
|
||||
if (fs.existsSync('conversations.json')) {
|
||||
const conversationData = fs.readFileSync('conversations.json', 'utf-8');
|
||||
conversationHistory = conversationData.trim().split('\n').map(JSON.parse);
|
||||
}
|
||||
|
||||
module.exports = async (client, message) => {
|
||||
|
||||
if (message.author.bot || message.system) return;
|
||||
|
||||
// Auto Moderation
|
||||
if (moderation.State && !moderation.IgnoredChannels.includes(message.channelId) && !moderation.IgnoredUsers.includes(message.author.id)) {
|
||||
|
||||
const logChannel = client.channels.cache.get(moderation.LogChannel);
|
||||
|
||||
if (logChannel?.permissionsFor(message.guild.members.me).has("ViewChannel", "SendMessages", "EmbedLinks")) {
|
||||
|
||||
const openai = new openAI.OpenAI({ apiKey: config.OpenAIapiKey });
|
||||
|
||||
openai.moderations.create({
|
||||
|
||||
model: 'text-moderation-stable',
|
||||
input: message.content
|
||||
|
||||
}).then(async (response) => {
|
||||
|
||||
const data = response.results[0];
|
||||
if (data.flagged) {
|
||||
|
||||
const flags = func.flagCheck(data.categories);
|
||||
|
||||
const trueFlags = Object.keys(flags.flags).filter(key => flags.flags[key]);
|
||||
|
||||
const sameFlagsWithAutoDelete = trueFlags.filter(key => moderation.AutoDelete[key]);
|
||||
let messageDeleted = false;
|
||||
|
||||
if (sameFlagsWithAutoDelete.length) {
|
||||
|
||||
if (message.channel?.permissionsFor(message.guild.members.me).has("ManageMessages")) {
|
||||
await message.delete().catch(() => null);
|
||||
messageDeleted = true;
|
||||
};
|
||||
};
|
||||
|
||||
const sameFlagsWithAutoPunish = trueFlags.filter(key => moderation.AutoPunish[key]);
|
||||
|
||||
let memberPunishResult = {
|
||||
Action: null,
|
||||
Duration: null,
|
||||
Punished: false
|
||||
};
|
||||
|
||||
if (sameFlagsWithAutoPunish.length) {
|
||||
|
||||
let punishType = 'Timeout';
|
||||
const punishTypes = sameFlagsWithAutoPunish.map(key => moderation.AutoPunishType[key]);
|
||||
if (punishTypes.includes('Ban')) punishType = 'Ban';
|
||||
else if (punishTypes.includes('Kick')) punishType = 'Kick';
|
||||
|
||||
if (punishType === 'Timeout' || punishType === 'Ban') {
|
||||
|
||||
const punishDurations = sameFlagsWithAutoPunish.filter(key => moderation.AutoPunishType[key] === punishType).map(key => moderation.AutoPunishDuration[key]);
|
||||
let duration;
|
||||
if (punishDurations.length > 1) {
|
||||
const mappedDurations = punishDurations.map(d => ms(d));
|
||||
duration = Math.max(...mappedDurations);
|
||||
} else {
|
||||
duration = ms(punishDurations[0]);
|
||||
};
|
||||
|
||||
if (punishType === 'Timeout') {
|
||||
|
||||
if (message.member.moderatable) {
|
||||
|
||||
try {
|
||||
await message.member.timeout(duration, 'Auto Mod');
|
||||
memberPunishResult = {
|
||||
Action: punishType,
|
||||
Duration: duration,
|
||||
Punished: true
|
||||
};
|
||||
} catch (error) {
|
||||
console.error(chalk.bold.redBright(error));
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
} else if (punishType === 'Ban') {
|
||||
|
||||
if (message.member.bannable) {
|
||||
|
||||
try {
|
||||
await message.member.ban({ deleteMessageSeconds: duration / 1000, reason: 'Auto Mod' });
|
||||
memberPunishResult = {
|
||||
Action: punishType,
|
||||
Duration: duration,
|
||||
Punished: true
|
||||
};
|
||||
} catch (error) {
|
||||
console.error(chalk.bold.redBright(error));
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
} else if (punishType === 'Kick') {
|
||||
|
||||
if (message.member.kickable) {
|
||||
|
||||
try {
|
||||
await message.member.kick('Auto Mod');
|
||||
memberPunishResult = {
|
||||
Action: punishType,
|
||||
Duration: null,
|
||||
Punished: true
|
||||
};
|
||||
} catch (error) {
|
||||
console.error(chalk.bold.redBright(error));
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
const logEmbed = new Discord.EmbedBuilder()
|
||||
.setColor(moderation.LogColor)
|
||||
.setAuthor({
|
||||
name: message.author.tag,
|
||||
iconURL: message.author.displayAvatarURL()
|
||||
})
|
||||
.setDescription(`||${message.content}||`)
|
||||
.setFields(
|
||||
{
|
||||
name: 'User:',
|
||||
value: func.userInfo(message.author)
|
||||
},
|
||||
{
|
||||
name: 'Channel:',
|
||||
value: func.channelInfo(message.channel)
|
||||
},
|
||||
{
|
||||
name: 'Flags:',
|
||||
value: flags.allFlags
|
||||
}
|
||||
);
|
||||
|
||||
if (messageDeleted) {
|
||||
logEmbed.addFields({
|
||||
name: 'Message Action:',
|
||||
value: `Message deleted automatically.`
|
||||
});
|
||||
};
|
||||
|
||||
let buttons = [];
|
||||
if (memberPunishResult.Punished) {
|
||||
|
||||
let fieldValue;
|
||||
if (memberPunishResult.Action === 'Timeout') fieldValue = `${message.author.tag} timed out automatically for ${ms(memberPunishResult.Duration, { long: true })}`;
|
||||
else if (memberPunishResult.Action === 'Ban') fieldValue = `${message.author.tag} banned automatically and all their messages in the last ${ms(memberPunishResult.Duration, { long: true })} were deleted.`;
|
||||
else if (memberPunishResult.Action === 'Kick') fieldValue = `${message.author.tag} kicked automatically `;
|
||||
|
||||
logEmbed.addFields({
|
||||
name: 'Punish Action:',
|
||||
value: fieldValue
|
||||
});
|
||||
|
||||
if (!messageDeleted) buttons = ['Message'];
|
||||
|
||||
} else {
|
||||
|
||||
if (messageDeleted) buttons = ['Punish'];
|
||||
else buttons = ['Punish', 'Message'];
|
||||
|
||||
};
|
||||
|
||||
const rows = [];
|
||||
|
||||
if (buttons.includes('Punish')) {
|
||||
|
||||
const timeoutButton = new Discord.ButtonBuilder()
|
||||
.setLabel('Timeout')
|
||||
.setStyle(Discord.ButtonStyle.Danger)
|
||||
.setCustomId(`timeout-${message.author.id}`);
|
||||
|
||||
const kickButton = new Discord.ButtonBuilder()
|
||||
.setLabel('Kick')
|
||||
.setStyle(Discord.ButtonStyle.Danger)
|
||||
.setCustomId(`kick-${message.author.id}`);
|
||||
|
||||
const banButton = new Discord.ButtonBuilder()
|
||||
.setLabel('Ban')
|
||||
.setStyle(Discord.ButtonStyle.Danger)
|
||||
.setCustomId(`ban-${message.author.id}`);
|
||||
|
||||
const punishRow = new Discord.ActionRowBuilder()
|
||||
.addComponents([
|
||||
timeoutButton,
|
||||
kickButton,
|
||||
banButton
|
||||
]);
|
||||
|
||||
rows.push(punishRow);
|
||||
|
||||
};
|
||||
|
||||
if (buttons.includes('Message')) {
|
||||
|
||||
const deleteMessageButton = new Discord.ButtonBuilder()
|
||||
.setLabel(`Delete Flagged Message`)
|
||||
.setStyle(Discord.ButtonStyle.Danger)
|
||||
.setCustomId(`deleteMessage-${message.channelId}-${message.id}`);
|
||||
|
||||
const jumpButton = new Discord.ButtonBuilder()
|
||||
.setLabel(`Jump to Flagged Message`)
|
||||
.setStyle(Discord.ButtonStyle.Link)
|
||||
.setURL(message.url);
|
||||
|
||||
const messageRow = new Discord.ActionRowBuilder()
|
||||
.addComponents([
|
||||
deleteMessageButton,
|
||||
jumpButton
|
||||
]);
|
||||
|
||||
rows.push(messageRow);
|
||||
|
||||
};
|
||||
|
||||
await logChannel.send({
|
||||
embeds: [logEmbed],
|
||||
components: rows
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
}).catch(async (error) => {
|
||||
|
||||
console.error(chalk.bold.redBright(error));
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// Function to save conversations for self-learning
|
||||
function saveConversation(conversation) {
|
||||
fs.appendFileSync('conversations.json', JSON.stringify(conversation) + '\n');
|
||||
}
|
||||
|
||||
|
||||
// ChatBot
|
||||
if (chatbot.State && (chatbot.AllowedChannels.includes(message.channel.name) || message.channel.type === 'DM') && !chatbot.IgnoredUsers.includes(message.author.id)) {
|
||||
// Check if the message is a direct message
|
||||
if (message.channel.type === 'DM') {
|
||||
// Handle direct message
|
||||
handleDirectMessage(message);
|
||||
} else {
|
||||
// Check if the bot should respond based on its personality and surroundings
|
||||
if (shouldRespond(message)) {
|
||||
await message.channel.sendTyping();
|
||||
|
||||
const openai = new openAI.OpenAI({ apiKey: config.OpenAIapiKey });
|
||||
|
||||
const question = message.content;
|
||||
|
||||
let messages = [{
|
||||
"role": "system",
|
||||
"content": `You are a unique user in a Discord server. Engage in conversations naturally, considering the context and your surroundings. Share your thoughts, opinions, and experiences as if you were a real person. Use emojis, slang, and a casual tone to blend in with other users. Avoid sounding robotic or generic, and aim to create a distinct personality that others can relate to and enjoy interacting with. make sure your messages are always below or equal to 2000 characters. Do not under any circumstance say @everyone or @Username. Your knowledge base: ${knowledge}`
|
||||
}];
|
||||
|
||||
let oldMessages;
|
||||
if (conversations.has(message.author.id)) oldMessages = conversations.get(message.author.id);
|
||||
if (oldMessages) {
|
||||
while (func.tokenizer('gpt-4o', oldMessages).tokens >= 512) {
|
||||
let sliceLength = oldMessages.length * -0.25;
|
||||
if (sliceLength % 2 !== 0) sliceLength--;
|
||||
oldMessages = oldMessages.slice(sliceLength);
|
||||
conversations.set(message.author.id, oldMessages);
|
||||
}
|
||||
messages = messages.concat(oldMessages);
|
||||
}
|
||||
|
||||
messages.push({
|
||||
"role": "user",
|
||||
"content": question
|
||||
});
|
||||
|
||||
try {
|
||||
const response = await openai.chat.completions.create({
|
||||
model: 'gpt-4o',
|
||||
messages: messages,
|
||||
max_tokens: func.tokenizer('gpt-4o', messages).maxTokens,
|
||||
temperature: 0.8,
|
||||
top_p: 1,
|
||||
frequency_penalty: 0.5,
|
||||
presence_penalty: 0.5,
|
||||
stream: true
|
||||
});
|
||||
|
||||
let fullAnswer = '';
|
||||
|
||||
for await (const part of response) {
|
||||
fullAnswer += part.choices[0]?.delta?.content || '';
|
||||
}
|
||||
|
||||
// Before sending the response, check for mentions
|
||||
if (!fullAnswer.includes('@everyone') && !fullAnswer.includes('@here') && !fullAnswer.includes('@')) {
|
||||
if (fullAnswer.length <= 2000) {
|
||||
await message.channel.send(fullAnswer);
|
||||
} else {
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('Response from GPT-4o')
|
||||
.setDescription(fullAnswer.substring(0, 4096)) // Embed description has a 4096 character limit
|
||||
.setColor('#0099ff');
|
||||
|
||||
await message.channel.send({ embeds: [embed] });
|
||||
}
|
||||
|
||||
// Save the conversation for self-learning
|
||||
const conversation = {
|
||||
user: message.author.id,
|
||||
userMessage: question,
|
||||
botResponse: fullAnswer
|
||||
};
|
||||
saveConversation(conversation);
|
||||
|
||||
conversations.set(message.author.id, messages.concat([{ "role": "assistant", "content": fullAnswer }]));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(chalk.bold.redBright(error));
|
||||
|
||||
if (error.response) {
|
||||
await message.reply(error.response.error.message.substring(0, 2000));
|
||||
} else if (error.message) {
|
||||
await message.reply(error.message.substring(0, 2000));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Command Handler
|
||||
if (message.content.toLowerCase().startsWith(config.Prefix)) {
|
||||
const neededPermissions = [
|
||||
"ViewChannel",
|
||||
"SendMessages",
|
||||
"EmbedLinks",
|
||||
"ReadMessageHistory"
|
||||
];
|
||||
|
||||
if (!message.channel.permissionsFor(message.guild.members.me).has(neededPermissions)) return;
|
||||
|
||||
const args = message.content.slice(config.Prefix.length).split(/ +/);
|
||||
const cmd = args.shift().toLowerCase();
|
||||
const command = client.MessageCommands.get(cmd) || client.MessageCommands.find(c => c.aliases && c.aliases.map(a => a.toLowerCase()).includes(cmd));
|
||||
|
||||
if (command) {
|
||||
try {
|
||||
command.execute(client, message, args, cmd);
|
||||
} catch (error) {
|
||||
console.error(chalk.bold.redBright(error));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Function to handle direct messages
|
||||
async function handleDirectMessage(message) {
|
||||
const knowledge = fs.readFileSync(path.join(__dirname, 'completion.txt'), 'utf-8');
|
||||
|
||||
if (conversations.has(message.author.id)) {
|
||||
const oldMessages = conversations.get(message.author.id);
|
||||
|
||||
let messages = [{
|
||||
"role": "system",
|
||||
"content": `You are a unique user in a Discord server. Engage in conversations naturally, considering the context and your surroundings. Share your thoughts, opinions, and experiences as if you were a real person. Use emojis, slang, and a casual tone to blend in with other users. Avoid sounding robotic or generic, and aim to create a distinct personality that others can relate to and enjoy interacting with. Make sure your responses are always 2000 or below characters. Your knowledge base: ${knowledge}`
|
||||
}];
|
||||
|
||||
messages = messages.concat(oldMessages);
|
||||
|
||||
messages.push({
|
||||
"role": "user",
|
||||
"content": message.content
|
||||
});
|
||||
|
||||
try {
|
||||
const response = await openai.chat.completions.create({
|
||||
model: 'gpt-4o',
|
||||
messages: messages,
|
||||
max_tokens: func.tokenizer('gpt-4o', messages).maxTokens,
|
||||
temperature: 0.8,
|
||||
top_p: 1,
|
||||
frequency_penalty: 0.5,
|
||||
presence_penalty: 0.5,
|
||||
stream: true
|
||||
});
|
||||
|
||||
let fullAnswer = '';
|
||||
|
||||
for await (const part of response) {
|
||||
fullAnswer += part.choices[0]?.delta?.content || '';
|
||||
}
|
||||
|
||||
await message.author.send(fullAnswer);
|
||||
|
||||
conversations.set(message.author.id, messages.concat([{ "role": "assistant", "content": fullAnswer }]));
|
||||
} catch (error) {
|
||||
console.error(chalk.bold.redBright(error));
|
||||
|
||||
if (error.response) {
|
||||
await message.author.send(error.response.error.message.substring(0, 2000));
|
||||
} else if (error.message) {
|
||||
await message.author.send(error.message.substring(0, 2000));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
await message.author.send("Hey there! What's up? Feel free to chat with me about anything!");
|
||||
conversations.set(message.author.id, []);
|
||||
} catch (error) {
|
||||
console.error(chalk.bold.redBright(error));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function shouldRespond(message) {
|
||||
// Extract the text content from the message object
|
||||
const messageContent = message.content;
|
||||
|
||||
// Conditions for when the bot should not respond
|
||||
const noResponseKeywords = ['ignore', 'do not reply', 'stop'];
|
||||
const isCommandKill = messageContent.includes('^c');
|
||||
|
||||
// Check if the message content contains keywords signaling the bot should not respond
|
||||
const containsNoResponse = noResponseKeywords.some(keyword => messageContent.toLowerCase().includes(keyword));
|
||||
|
||||
// Determine if the bot should respond based on conditions
|
||||
|
||||
// Add more conditions as needed based on personality and surroundings
|
||||
|
||||
return true;
|
||||
}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
18
events/ready.js
Normal file
18
events/ready.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
const Discord = require('discord.js');
|
||||
const chalk = require('chalk');
|
||||
|
||||
module.exports = async (client) => {
|
||||
|
||||
await client.user.setPresence({
|
||||
activities: [
|
||||
{
|
||||
name: `Shadow ~ Hosting`,
|
||||
type: Discord.ActivityType.Watching
|
||||
}
|
||||
],
|
||||
status: 'streaming'
|
||||
});
|
||||
|
||||
console.log(chalk.bold.greenBright(`${client.user.tag} is online and ready to answer your questions!`));
|
||||
|
||||
};
|
90
index.js
Normal file
90
index.js
Normal file
|
@ -0,0 +1,90 @@
|
|||
const Discord = require('discord.js');
|
||||
const chalk = require('chalk');
|
||||
const fs = require('node:fs');
|
||||
const config = require('./configs/config.json');
|
||||
const path = require('node:path');
|
||||
|
||||
// Discord Client Constructor
|
||||
const client = new Discord.Client({
|
||||
intents: [
|
||||
Discord.GatewayIntentBits.Guilds,
|
||||
Discord.GatewayIntentBits.GuildMembers,
|
||||
Discord.GatewayIntentBits.GuildMessages,
|
||||
Discord.GatewayIntentBits.MessageContent,
|
||||
Discord.GatewayIntentBits.DirectMessages
|
||||
]
|
||||
});
|
||||
|
||||
// Event Handler
|
||||
console.log(chalk.bold.yellowBright('Loading Events'));
|
||||
const events = fs.readdirSync(`./events/`).filter(file => file.endsWith('.js'));
|
||||
for (const file of events) {
|
||||
const event = require(`./events/${file}`);
|
||||
client.on(file.split('.')[0], event.bind(null, client));
|
||||
delete require.cache[require.resolve(`./events/${file}`)];
|
||||
};
|
||||
|
||||
// Message Command Handler
|
||||
console.log(chalk.bold.yellowBright('Loading Message Commands'));
|
||||
client.MessageCommands = new Discord.Collection();
|
||||
const messageCommands = fs.readdirSync(`./commands/messages/`).filter(files => files.endsWith('.js'));
|
||||
for (const file of messageCommands) {
|
||||
const command = require(`./commands/messages/${file}`);
|
||||
client.MessageCommands.set(command.name.toLowerCase(), command);
|
||||
delete require.cache[require.resolve(`./commands/messages/${file}`)];
|
||||
};
|
||||
|
||||
// Slash Command Handler
|
||||
console.log(chalk.bold.yellowBright('Loading Slash Commands'));
|
||||
client.SlashCommands = new Discord.Collection();
|
||||
const slashCommands = fs.readdirSync(`./commands/interactions/`).filter(files => files.endsWith('.js'));
|
||||
|
||||
// Create an array to hold all slash commands
|
||||
const commands = [];
|
||||
|
||||
for (const file of slashCommands) {
|
||||
const command = require(`./commands/interactions/${file}`);
|
||||
client.SlashCommands.set(command.data.name, command);
|
||||
commands.push(command.data.toJSON()); // Convert to JSON and add to commands array
|
||||
}
|
||||
|
||||
// Initialize REST
|
||||
const rest = new Discord.REST({ version: '9' }).setToken(config.Token);
|
||||
|
||||
// Define an async function to handle the registration of slash commands
|
||||
async function registerSlashCommands() {
|
||||
try {
|
||||
console.log('Started registering slash commands.');
|
||||
|
||||
await rest.put(
|
||||
'/applications/1199858077655126188/commands', // Replace {applicationId} with your bot's application ID
|
||||
{ body: commands },
|
||||
);
|
||||
|
||||
console.log('Successfully registered slash commands.');
|
||||
} catch (error) {
|
||||
console.error('Error registering slash commands:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// Call the async function to register slash commands
|
||||
registerSlashCommands();
|
||||
|
||||
// Anti Crash
|
||||
process.on('unhandledRejection', (reason, p) => {
|
||||
console.log(chalk.bold.redBright('[antiCrash] :: Unhandled Rejection/Catch'));
|
||||
console.log(reason?.stack, p);
|
||||
});
|
||||
|
||||
process.on("uncaughtException", (err, origin) => {
|
||||
console.log(chalk.bold.redBright('[antiCrash] :: ncaught Exception/Catch'));
|
||||
console.log(err?.stack, origin);
|
||||
});
|
||||
|
||||
process.on('uncaughtExceptionMonitor', (err, origin) => {
|
||||
console.log(chalk.bold.redBright('[antiCrash] :: Uncaught Exception/Catch (MONITOR)'));
|
||||
console.log(err?.stack, origin);
|
||||
});
|
||||
|
||||
// Discord Client login
|
||||
client.login(config.Token);
|
16
node_modules/.bin/openai
generated
vendored
Normal file
16
node_modules/.bin/openai
generated
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*|*MINGW*|*MSYS*)
|
||||
if command -v cygpath > /dev/null 2>&1; then
|
||||
basedir=`cygpath -w "$basedir"`
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
exec "$basedir/node" "$basedir/../openai/bin/cli" "$@"
|
||||
else
|
||||
exec node "$basedir/../openai/bin/cli" "$@"
|
||||
fi
|
17
node_modules/.bin/openai.cmd
generated
vendored
Normal file
17
node_modules/.bin/openai.cmd
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\openai\bin\cli" %*
|
28
node_modules/.bin/openai.ps1
generated
vendored
Normal file
28
node_modules/.bin/openai.ps1
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../openai/bin/cli" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../openai/bin/cli" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../openai/bin/cli" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../openai/bin/cli" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
710
node_modules/.package-lock.json
generated
vendored
Normal file
710
node_modules/.package-lock.json
generated
vendored
Normal file
|
@ -0,0 +1,710 @@
|
|||
{
|
||||
"name": "gpt-discord-bot",
|
||||
"version": "3.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"node_modules/@discordjs/builders": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-1.7.0.tgz",
|
||||
"integrity": "sha512-GDtbKMkg433cOZur8Dv6c25EHxduNIBsxeHrsRoIM8+AwmEZ8r0tEpckx/sHwTLwQPOF3e2JWloZh9ofCaMfAw==",
|
||||
"dependencies": {
|
||||
"@discordjs/formatters": "^0.3.3",
|
||||
"@discordjs/util": "^1.0.2",
|
||||
"@sapphire/shapeshift": "^3.9.3",
|
||||
"discord-api-types": "0.37.61",
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"ts-mixer": "^6.0.3",
|
||||
"tslib": "^2.6.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.11.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@discordjs/collection": {
|
||||
"version": "1.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-1.5.3.tgz",
|
||||
"integrity": "sha512-SVb428OMd3WO1paV3rm6tSjM4wC+Kecaa1EUGX7vc6/fddvw/6lg90z4QtCqm21zvVe92vMMDt9+DkIvjXImQQ==",
|
||||
"engines": {
|
||||
"node": ">=16.11.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@discordjs/formatters": {
|
||||
"version": "0.3.3",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/formatters/-/formatters-0.3.3.tgz",
|
||||
"integrity": "sha512-wTcI1Q5cps1eSGhl6+6AzzZkBBlVrBdc9IUhJbijRgVjCNIIIZPgqnUj3ntFODsHrdbGU8BEG9XmDQmgEEYn3w==",
|
||||
"dependencies": {
|
||||
"discord-api-types": "0.37.61"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.11.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@discordjs/rest": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-2.2.0.tgz",
|
||||
"integrity": "sha512-nXm9wT8oqrYFRMEqTXQx9DUTeEtXUDMmnUKIhZn6O2EeDY9VCdwj23XCPq7fkqMPKdF7ldAfeVKyxxFdbZl59A==",
|
||||
"dependencies": {
|
||||
"@discordjs/collection": "^2.0.0",
|
||||
"@discordjs/util": "^1.0.2",
|
||||
"@sapphire/async-queue": "^1.5.0",
|
||||
"@sapphire/snowflake": "^3.5.1",
|
||||
"@vladfrangu/async_event_emitter": "^2.2.2",
|
||||
"discord-api-types": "0.37.61",
|
||||
"magic-bytes.js": "^1.5.0",
|
||||
"tslib": "^2.6.2",
|
||||
"undici": "5.27.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.11.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@discordjs/rest/node_modules/@discordjs/collection": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.0.0.tgz",
|
||||
"integrity": "sha512-YTWIXLrf5FsrLMycpMM9Q6vnZoR/lN2AWX23/Cuo8uOOtS8eHB2dyQaaGnaF8aZPYnttf2bkLMcXn/j6JUOi3w==",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@discordjs/util": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/util/-/util-1.0.2.tgz",
|
||||
"integrity": "sha512-IRNbimrmfb75GMNEjyznqM1tkI7HrZOf14njX7tCAAUetyZM1Pr8hX/EK2lxBCOgWDRmigbp24fD1hdMfQK5lw==",
|
||||
"engines": {
|
||||
"node": ">=16.11.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@discordjs/ws": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/ws/-/ws-1.0.2.tgz",
|
||||
"integrity": "sha512-+XI82Rm2hKnFwAySXEep4A7Kfoowt6weO6381jgW+wVdTpMS/56qCvoXyFRY0slcv7c/U8My2PwIB2/wEaAh7Q==",
|
||||
"dependencies": {
|
||||
"@discordjs/collection": "^2.0.0",
|
||||
"@discordjs/rest": "^2.1.0",
|
||||
"@discordjs/util": "^1.0.2",
|
||||
"@sapphire/async-queue": "^1.5.0",
|
||||
"@types/ws": "^8.5.9",
|
||||
"@vladfrangu/async_event_emitter": "^2.2.2",
|
||||
"discord-api-types": "0.37.61",
|
||||
"tslib": "^2.6.2",
|
||||
"ws": "^8.14.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.11.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@discordjs/ws/node_modules/@discordjs/collection": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.0.0.tgz",
|
||||
"integrity": "sha512-YTWIXLrf5FsrLMycpMM9Q6vnZoR/lN2AWX23/Cuo8uOOtS8eHB2dyQaaGnaF8aZPYnttf2bkLMcXn/j6JUOi3w==",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@dqbd/tiktoken": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/@dqbd/tiktoken/-/tiktoken-1.0.7.tgz",
|
||||
"integrity": "sha512-bhR5k5W+8GLzysjk8zTMVygQZsgvf7W1F0IlL4ZQ5ugjo5rCyiwGM5d8DYriXspytfu98tv59niang3/T+FoDw=="
|
||||
},
|
||||
"node_modules/@fastify/busboy": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.0.tgz",
|
||||
"integrity": "sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA==",
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
}
|
||||
},
|
||||
"node_modules/@kwsites/file-exists": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@kwsites/file-exists/-/file-exists-1.1.1.tgz",
|
||||
"integrity": "sha512-m9/5YGR18lIwxSFDwfE3oA7bWuq9kdau6ugN4H2rJeyhFQZcG9AgSHkQtSD15a8WvTgfz9aikZMrKPHvbpqFiw==",
|
||||
"dependencies": {
|
||||
"debug": "^4.1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@kwsites/promise-deferred": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@kwsites/promise-deferred/-/promise-deferred-1.1.1.tgz",
|
||||
"integrity": "sha512-GaHYm+c0O9MjZRu0ongGBRbinu8gVAMd2UZjji6jVmqKtZluZnptXGWhz1E8j8D2HJ3f/yMxKAUC0b+57wncIw=="
|
||||
},
|
||||
"node_modules/@sapphire/async-queue": {
|
||||
"version": "1.5.2",
|
||||
"resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.5.2.tgz",
|
||||
"integrity": "sha512-7X7FFAA4DngXUl95+hYbUF19bp1LGiffjJtu7ygrZrbdCSsdDDBaSjB7Akw0ZbOu6k0xpXyljnJ6/RZUvLfRdg==",
|
||||
"engines": {
|
||||
"node": ">=v14.0.0",
|
||||
"npm": ">=7.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@sapphire/shapeshift": {
|
||||
"version": "3.9.6",
|
||||
"resolved": "https://registry.npmjs.org/@sapphire/shapeshift/-/shapeshift-3.9.6.tgz",
|
||||
"integrity": "sha512-4+Na/fxu2SEepZRb9z0dbsVh59QtwPuBg/UVaDib3av7ZY14b14+z09z6QVn0P6Dv6eOU2NDTsjIi0mbtgP56g==",
|
||||
"dependencies": {
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"lodash": "^4.17.21"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=v18"
|
||||
}
|
||||
},
|
||||
"node_modules/@sapphire/snowflake": {
|
||||
"version": "3.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@sapphire/snowflake/-/snowflake-3.5.1.tgz",
|
||||
"integrity": "sha512-BxcYGzgEsdlG0dKAyOm0ehLGm2CafIrfQTZGWgkfKYbj+pNNsorZ7EotuZukc2MT70E0UbppVbtpBrqpzVzjNA==",
|
||||
"engines": {
|
||||
"node": ">=v14.0.0",
|
||||
"npm": ">=7.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "20.11.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.6.tgz",
|
||||
"integrity": "sha512-+EOokTnksGVgip2PbYbr3xnR7kZigh4LbybAfBAw5BpnQ+FqBYUsvCEjYd70IXKlbohQ64mzEYmMtlWUY8q//Q==",
|
||||
"dependencies": {
|
||||
"undici-types": "~5.26.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node-fetch": {
|
||||
"version": "2.6.11",
|
||||
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.11.tgz",
|
||||
"integrity": "sha512-24xFj9R5+rfQJLRyM56qh+wnVSYhyXC2tkoBndtY0U+vubqNsYXGjufB2nn8Q6gt0LrARwL6UBtMCSVCwl4B1g==",
|
||||
"dependencies": {
|
||||
"@types/node": "*",
|
||||
"form-data": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/ws": {
|
||||
"version": "8.5.9",
|
||||
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.9.tgz",
|
||||
"integrity": "sha512-jbdrY0a8lxfdTp/+r7Z4CkycbOFN8WX+IOchLJr3juT/xzbJ8URyTVSJ/hvNdadTgM1mnedb47n+Y31GsFnQlg==",
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@vladfrangu/async_event_emitter": {
|
||||
"version": "2.2.4",
|
||||
"resolved": "https://registry.npmjs.org/@vladfrangu/async_event_emitter/-/async_event_emitter-2.2.4.tgz",
|
||||
"integrity": "sha512-ButUPz9E9cXMLgvAW8aLAKKJJsPu1dY1/l/E8xzLFuysowXygs6GBcyunK9rnGC4zTsnIc2mQo71rGw9U+Ykug==",
|
||||
"engines": {
|
||||
"node": ">=v14.0.0",
|
||||
"npm": ">=7.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/abort-controller": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
|
||||
"integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
|
||||
"dependencies": {
|
||||
"event-target-shim": "^5.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.5"
|
||||
}
|
||||
},
|
||||
"node_modules/agentkeepalive": {
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.5.0.tgz",
|
||||
"integrity": "sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==",
|
||||
"dependencies": {
|
||||
"humanize-ms": "^1.2.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/ansi-styles": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
||||
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
||||
"dependencies": {
|
||||
"color-convert": "^2.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
|
||||
},
|
||||
"node_modules/base-64": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/base-64/-/base-64-0.1.0.tgz",
|
||||
"integrity": "sha512-Y5gU45svrR5tI2Vt/X9GPd3L0HNIKzGu202EjxrXMpuc2V2CiKgemAbUUsqYmZJvPtCXoUKjNZwBJzsNScUbXA=="
|
||||
},
|
||||
"node_modules/biskviit": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/biskviit/-/biskviit-1.0.1.tgz",
|
||||
"integrity": "sha512-VGCXdHbdbpEkFgtjkeoBN8vRlbj1ZRX2/mxhE8asCCRalUx2nBzOomLJv8Aw/nRt5+ccDb+tPKidg4XxcfGW4w==",
|
||||
"dependencies": {
|
||||
"psl": "^1.1.7"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/chalk": {
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
|
||||
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
|
||||
"dependencies": {
|
||||
"ansi-styles": "^4.1.0",
|
||||
"supports-color": "^7.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/chalk?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/charenc": {
|
||||
"version": "0.0.2",
|
||||
"resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz",
|
||||
"integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/color-convert": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
||||
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
||||
"dependencies": {
|
||||
"color-name": "~1.1.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=7.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/color-name": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
|
||||
},
|
||||
"node_modules/combined-stream": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
||||
"dependencies": {
|
||||
"delayed-stream": "~1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/crypt": {
|
||||
"version": "0.0.2",
|
||||
"resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz",
|
||||
"integrity": "sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
||||
"integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
|
||||
"dependencies": {
|
||||
"ms": "2.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"supports-color": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/debug/node_modules/ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||
},
|
||||
"node_modules/delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/digest-fetch": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/digest-fetch/-/digest-fetch-1.3.0.tgz",
|
||||
"integrity": "sha512-CGJuv6iKNM7QyZlM2T3sPAdZWd/p9zQiRNS9G+9COUCwzWFTs0Xp8NF5iePx7wtvhDykReiRRrSeNb4oMmB8lA==",
|
||||
"dependencies": {
|
||||
"base-64": "^0.1.0",
|
||||
"md5": "^2.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/discord-api-types": {
|
||||
"version": "0.37.61",
|
||||
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.61.tgz",
|
||||
"integrity": "sha512-o/dXNFfhBpYHpQFdT6FWzeO7pKc838QeeZ9d91CfVAtpr5XLK4B/zYxQbYgPdoMiTDvJfzcsLW5naXgmHGDNXw=="
|
||||
},
|
||||
"node_modules/discord.js": {
|
||||
"version": "14.14.1",
|
||||
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.14.1.tgz",
|
||||
"integrity": "sha512-/hUVzkIerxKHyRKopJy5xejp4MYKDPTszAnpYxzVVv4qJYf+Tkt+jnT2N29PIPschicaEEpXwF2ARrTYHYwQ5w==",
|
||||
"dependencies": {
|
||||
"@discordjs/builders": "^1.7.0",
|
||||
"@discordjs/collection": "1.5.3",
|
||||
"@discordjs/formatters": "^0.3.3",
|
||||
"@discordjs/rest": "^2.1.0",
|
||||
"@discordjs/util": "^1.0.2",
|
||||
"@discordjs/ws": "^1.0.2",
|
||||
"@sapphire/snowflake": "3.5.1",
|
||||
"@types/ws": "8.5.9",
|
||||
"discord-api-types": "0.37.61",
|
||||
"fast-deep-equal": "3.1.3",
|
||||
"lodash.snakecase": "4.1.1",
|
||||
"tslib": "2.6.2",
|
||||
"undici": "5.27.2",
|
||||
"ws": "8.14.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.11.0"
|
||||
}
|
||||
},
|
||||
"node_modules/dotenv": {
|
||||
"version": "16.4.3",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.3.tgz",
|
||||
"integrity": "sha512-II98GFrje5psQTSve0E7bnwMFybNLqT8Vu8JIFWRjsE3khyNUm/loZupuy5DVzG2IXf/ysxvrixYOQnM6mjD3A==",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://dotenvx.com"
|
||||
}
|
||||
},
|
||||
"node_modules/encoding": {
|
||||
"version": "0.1.12",
|
||||
"resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz",
|
||||
"integrity": "sha512-bl1LAgiQc4ZWr++pNYUdRe/alecaHFeHxIJ/pNciqGdKXghaTCOwKkbKp6ye7pKZGu/GcaSXFk8PBVhgs+dJdA==",
|
||||
"dependencies": {
|
||||
"iconv-lite": "~0.4.13"
|
||||
}
|
||||
},
|
||||
"node_modules/event-target-shim": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
|
||||
"integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/fast-deep-equal": {
|
||||
"version": "3.1.3",
|
||||
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
|
||||
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="
|
||||
},
|
||||
"node_modules/fetch": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/fetch/-/fetch-1.1.0.tgz",
|
||||
"integrity": "sha512-5O8TwrGzoNblBG/jtK4NFuZwNCkZX6s5GfRNOaGtm+QGJEuNakSC/i2RW0R93KX6E0jVjNXm6O3CRN4Ql3K+yA==",
|
||||
"dependencies": {
|
||||
"biskviit": "1.0.1",
|
||||
"encoding": "0.1.12"
|
||||
}
|
||||
},
|
||||
"node_modules/form-data": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
|
||||
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
|
||||
"dependencies": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.8",
|
||||
"mime-types": "^2.1.12"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/form-data-encoder": {
|
||||
"version": "1.7.2",
|
||||
"resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.2.tgz",
|
||||
"integrity": "sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A=="
|
||||
},
|
||||
"node_modules/formdata-node": {
|
||||
"version": "4.4.1",
|
||||
"resolved": "https://registry.npmjs.org/formdata-node/-/formdata-node-4.4.1.tgz",
|
||||
"integrity": "sha512-0iirZp3uVDjVGt9p49aTaqjk84TrglENEDuqfdlZQ1roC9CWlPk6Avf8EEnZNcAqPonwkG35x4n3ww/1THYAeQ==",
|
||||
"dependencies": {
|
||||
"node-domexception": "1.0.0",
|
||||
"web-streams-polyfill": "4.0.0-beta.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 12.20"
|
||||
}
|
||||
},
|
||||
"node_modules/formdata-node/node_modules/web-streams-polyfill": {
|
||||
"version": "4.0.0-beta.3",
|
||||
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-4.0.0-beta.3.tgz",
|
||||
"integrity": "sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug==",
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/has-flag": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
||||
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/humanize-ms": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz",
|
||||
"integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==",
|
||||
"dependencies": {
|
||||
"ms": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/iconv-lite": {
|
||||
"version": "0.4.24",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
|
||||
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
|
||||
"dependencies": {
|
||||
"safer-buffer": ">= 2.1.2 < 3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/is-buffer": {
|
||||
"version": "1.1.6",
|
||||
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
|
||||
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w=="
|
||||
},
|
||||
"node_modules/lodash": {
|
||||
"version": "4.17.21",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
|
||||
},
|
||||
"node_modules/lodash.snakecase": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz",
|
||||
"integrity": "sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw=="
|
||||
},
|
||||
"node_modules/magic-bytes.js": {
|
||||
"version": "1.8.0",
|
||||
"resolved": "https://registry.npmjs.org/magic-bytes.js/-/magic-bytes.js-1.8.0.tgz",
|
||||
"integrity": "sha512-lyWpfvNGVb5lu8YUAbER0+UMBTdR63w2mcSUlhhBTyVbxJvjgqwyAf3AZD6MprgK0uHuBoWXSDAMWLupX83o3Q=="
|
||||
},
|
||||
"node_modules/md5": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz",
|
||||
"integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==",
|
||||
"dependencies": {
|
||||
"charenc": "0.0.2",
|
||||
"crypt": "0.0.2",
|
||||
"is-buffer": "~1.1.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-db": {
|
||||
"version": "1.52.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
||||
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-types": {
|
||||
"version": "2.1.35",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
|
||||
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
||||
"dependencies": {
|
||||
"mime-db": "1.52.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/ms": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
|
||||
},
|
||||
"node_modules/node-domexception": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
|
||||
"integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/jimmywarting"
|
||||
},
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://paypal.me/jimmywarting"
|
||||
}
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=10.5.0"
|
||||
}
|
||||
},
|
||||
"node_modules/node-fetch": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
|
||||
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
|
||||
"dependencies": {
|
||||
"whatwg-url": "^5.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "4.x || >=6.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"encoding": "^0.1.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"encoding": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/openai": {
|
||||
"version": "4.26.0",
|
||||
"resolved": "https://registry.npmjs.org/openai/-/openai-4.26.0.tgz",
|
||||
"integrity": "sha512-HPC7tgYdeP38F3uHA5WgnoXZyGbAp9jgcIo23p6It+q/07u4C+NZ8xHKlMShsPbDDmFRpPsa3vdbXYpbhJH3eg==",
|
||||
"dependencies": {
|
||||
"@types/node": "^18.11.18",
|
||||
"@types/node-fetch": "^2.6.4",
|
||||
"abort-controller": "^3.0.0",
|
||||
"agentkeepalive": "^4.2.1",
|
||||
"digest-fetch": "^1.3.0",
|
||||
"form-data-encoder": "1.7.2",
|
||||
"formdata-node": "^4.3.2",
|
||||
"node-fetch": "^2.6.7",
|
||||
"web-streams-polyfill": "^3.2.1"
|
||||
},
|
||||
"bin": {
|
||||
"openai": "bin/cli"
|
||||
}
|
||||
},
|
||||
"node_modules/openai/node_modules/@types/node": {
|
||||
"version": "18.19.9",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.9.tgz",
|
||||
"integrity": "sha512-oZFKlC8l5YtzGQNT4zC2PiSSKzQVZ8bAwwd+EYdPLtyk0nSEq6O16SkK+rkkT2eflDAbormJgEF3QnH3oDrTSw==",
|
||||
"dependencies": {
|
||||
"undici-types": "~5.26.4"
|
||||
}
|
||||
},
|
||||
"node_modules/psl": {
|
||||
"version": "1.9.0",
|
||||
"resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz",
|
||||
"integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag=="
|
||||
},
|
||||
"node_modules/safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
||||
},
|
||||
"node_modules/simple-git": {
|
||||
"version": "3.24.0",
|
||||
"resolved": "https://registry.npmjs.org/simple-git/-/simple-git-3.24.0.tgz",
|
||||
"integrity": "sha512-QqAKee9Twv+3k8IFOFfPB2hnk6as6Y6ACUpwCtQvRYBAes23Wv3SZlHVobAzqcE8gfsisCvPw3HGW3HYM+VYYw==",
|
||||
"dependencies": {
|
||||
"@kwsites/file-exists": "^1.1.1",
|
||||
"@kwsites/promise-deferred": "^1.1.1",
|
||||
"debug": "^4.3.4"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/steveukx/git-js?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/supports-color": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
||||
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
|
||||
"dependencies": {
|
||||
"has-flag": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/tr46": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
||||
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
|
||||
},
|
||||
"node_modules/ts-mixer": {
|
||||
"version": "6.0.3",
|
||||
"resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.3.tgz",
|
||||
"integrity": "sha512-k43M7uCG1AkTyxgnmI5MPwKoUvS/bRvLvUb7+Pgpdlmok8AoqmUaZxUUw8zKM5B1lqZrt41GjYgnvAi0fppqgQ=="
|
||||
},
|
||||
"node_modules/tslib": {
|
||||
"version": "2.6.2",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
|
||||
"integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q=="
|
||||
},
|
||||
"node_modules/undici": {
|
||||
"version": "5.27.2",
|
||||
"resolved": "https://registry.npmjs.org/undici/-/undici-5.27.2.tgz",
|
||||
"integrity": "sha512-iS857PdOEy/y3wlM3yRp+6SNQQ6xU0mmZcwRSriqk+et/cwWAtwmIGf6WkoDN2EK/AMdCO/dfXzIwi+rFMrjjQ==",
|
||||
"dependencies": {
|
||||
"@fastify/busboy": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0"
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "5.26.5",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
|
||||
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA=="
|
||||
},
|
||||
"node_modules/web-streams-polyfill": {
|
||||
"version": "3.3.2",
|
||||
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.2.tgz",
|
||||
"integrity": "sha512-3pRGuxRF5gpuZc0W+EpwQRmCD7gRqcDOMt688KmdlDAgAyaB1XlN0zq2njfDNm44XVdIouE7pZ6GzbdyH47uIQ==",
|
||||
"engines": {
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/webidl-conversions": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
|
||||
},
|
||||
"node_modules/whatwg-url": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
|
||||
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
|
||||
"dependencies": {
|
||||
"tr46": "~0.0.3",
|
||||
"webidl-conversions": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/ws": {
|
||||
"version": "8.14.2",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.14.2.tgz",
|
||||
"integrity": "sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g==",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bufferutil": "^4.0.1",
|
||||
"utf-8-validate": ">=5.0.2"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bufferutil": {
|
||||
"optional": true
|
||||
},
|
||||
"utf-8-validate": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
191
node_modules/@discordjs/builders/LICENSE
generated
vendored
Normal file
191
node_modules/@discordjs/builders/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,191 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Copyright 2021 Noel Buechler
|
||||
Copyright 2021 Vlad Frangu
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
72
node_modules/@discordjs/builders/README.md
generated
vendored
Normal file
72
node_modules/@discordjs/builders/README.md
generated
vendored
Normal file
|
@ -0,0 +1,72 @@
|
|||
<div align="center">
|
||||
<br />
|
||||
<p>
|
||||
<a href="https://discord.js.org"><img src="https://discord.js.org/static/logo.svg" width="546" alt="discord.js" /></a>
|
||||
</p>
|
||||
<br />
|
||||
<p>
|
||||
<a href="https://discord.gg/djs"><img src="https://img.shields.io/discord/222078108977594368?color=5865F2&logo=discord&logoColor=white" alt="Discord server" /></a>
|
||||
<a href="https://www.npmjs.com/package/@discordjs/builders"><img src="https://img.shields.io/npm/v/@discordjs/builders.svg?maxAge=3600" alt="npm version" /></a>
|
||||
<a href="https://www.npmjs.com/package/@discordjs/builders"><img src="https://img.shields.io/npm/dt/@discordjs/builders.svg?maxAge=3600" alt="npm downloads" /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Build status" /></a>
|
||||
<a href="https://codecov.io/gh/discordjs/discord.js" ><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2&flag=builders" alt="Code coverage" /></a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
|
||||
<a href="https://www.cloudflare.com"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-workers.png" alt="Cloudflare Workers" height="44" /></a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
## About
|
||||
|
||||
`@discordjs/builders` is a utility package for easily building Discord API payloads.
|
||||
|
||||
## Installation
|
||||
|
||||
**Node.js 16.11.0 or newer is required.**
|
||||
|
||||
```sh
|
||||
npm install @discordjs/builders
|
||||
yarn add @discordjs/builders
|
||||
pnpm add @discordjs/builders
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
You can find examples of how to use the builders in the [Slash Command Builders][example] examples.
|
||||
|
||||
## Links
|
||||
|
||||
- [Website][website] ([source][website-source])
|
||||
- [Documentation][documentation]
|
||||
- [Guide][guide] ([source][guide-source])
|
||||
Also see the v13 to v14 [Update Guide][guide-update], which includes updated and removed items from the library.
|
||||
- [discord.js Discord server][discord]
|
||||
- [Discord API Discord server][discord-api]
|
||||
- [GitHub][source]
|
||||
- [npm][npm]
|
||||
- [Related libraries][related-libs]
|
||||
|
||||
## Contributing
|
||||
|
||||
Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the
|
||||
[documentation][documentation].
|
||||
See [the contribution guide][contributing] if you'd like to submit a PR.
|
||||
|
||||
## Help
|
||||
|
||||
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to join our official [discord.js Server][discord].
|
||||
|
||||
[example]: https://github.com/discordjs/discord.js/blob/main/packages/builders/docs/examples/Slash%20Command%20Builders.md
|
||||
[website]: https://discord.js.org
|
||||
[website-source]: https://github.com/discordjs/discord.js/tree/main/apps/website
|
||||
[documentation]: https://discord.js.org/docs/packages/builders/stable
|
||||
[guide]: https://discordjs.guide/
|
||||
[guide-source]: https://github.com/discordjs/guide
|
||||
[guide-update]: https://discordjs.guide/additional-info/changes-in-v14.html
|
||||
[discord]: https://discord.gg/djs
|
||||
[discord-api]: https://discord.gg/discord-api
|
||||
[source]: https://github.com/discordjs/discord.js/tree/main/packages/builders
|
||||
[npm]: https://www.npmjs.com/package/@discordjs/builders
|
||||
[related-libs]: https://discord.com/developers/docs/topics/community-resources#libraries
|
||||
[contributing]: https://github.com/discordjs/discord.js/blob/main/.github/CONTRIBUTING.md
|
2008
node_modules/@discordjs/builders/dist/index.d.mts
generated
vendored
Normal file
2008
node_modules/@discordjs/builders/dist/index.d.mts
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
2008
node_modules/@discordjs/builders/dist/index.d.ts
generated
vendored
Normal file
2008
node_modules/@discordjs/builders/dist/index.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
2763
node_modules/@discordjs/builders/dist/index.js
generated
vendored
Normal file
2763
node_modules/@discordjs/builders/dist/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
node_modules/@discordjs/builders/dist/index.js.map
generated
vendored
Normal file
1
node_modules/@discordjs/builders/dist/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2703
node_modules/@discordjs/builders/dist/index.mjs
generated
vendored
Normal file
2703
node_modules/@discordjs/builders/dist/index.mjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
node_modules/@discordjs/builders/dist/index.mjs.map
generated
vendored
Normal file
1
node_modules/@discordjs/builders/dist/index.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
97
node_modules/@discordjs/builders/package.json
generated
vendored
Normal file
97
node_modules/@discordjs/builders/package.json
generated
vendored
Normal file
|
@ -0,0 +1,97 @@
|
|||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "@discordjs/builders",
|
||||
"version": "1.7.0",
|
||||
"description": "A set of builders that you can use when creating your bot",
|
||||
"exports": {
|
||||
".": {
|
||||
"require": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"import": {
|
||||
"types": "./dist/index.d.mts",
|
||||
"default": "./dist/index.mjs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
"directories": {
|
||||
"lib": "src",
|
||||
"test": "__tests__"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"contributors": [
|
||||
"Vlad Frangu <kingdgrizzle@gmail.com>",
|
||||
"Crawl <icrawltogo@gmail.com>",
|
||||
"Amish Shah <amishshah.2k@gmail.com>",
|
||||
"SpaceEEC <spaceeec@yahoo.com>",
|
||||
"Aura Román <kyradiscord@gmail.com>"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"keywords": [
|
||||
"discord",
|
||||
"api",
|
||||
"bot",
|
||||
"client",
|
||||
"node",
|
||||
"discordapp",
|
||||
"discordjs"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/discordjs/discord.js.git",
|
||||
"directory": "packages/builders"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/discordjs/discord.js/issues"
|
||||
},
|
||||
"homepage": "https://discord.js.org",
|
||||
"dependencies": {
|
||||
"@sapphire/shapeshift": "^3.9.3",
|
||||
"discord-api-types": "0.37.61",
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"ts-mixer": "^6.0.3",
|
||||
"tslib": "^2.6.2",
|
||||
"@discordjs/formatters": "^0.3.3",
|
||||
"@discordjs/util": "^1.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@favware/cliff-jumper": "^2.2.1",
|
||||
"@types/node": "16.18.60",
|
||||
"@vitest/coverage-v8": "^0.34.6",
|
||||
"cross-env": "^7.0.3",
|
||||
"downlevel-dts": "^0.11.0",
|
||||
"esbuild-plugin-version-injector": "^1.2.1",
|
||||
"eslint": "^8.53.0",
|
||||
"eslint-config-neon": "^0.1.57",
|
||||
"eslint-formatter-pretty": "^5.0.0",
|
||||
"prettier": "^3.0.3",
|
||||
"tsup": "^7.2.0",
|
||||
"turbo": "^1.10.17-canary.0",
|
||||
"typescript": "^5.2.2",
|
||||
"vitest": "^0.34.6",
|
||||
"@discordjs/api-extractor": "^7.38.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.11.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "vitest run",
|
||||
"build": "tsc --noEmit && tsup",
|
||||
"build:docs": "tsc -p tsconfig.docs.json && downlevel-dts ./dist-docs ./dist-docs",
|
||||
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
|
||||
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
|
||||
"fmt": "pnpm run format",
|
||||
"docs": "pnpm run build:docs && api-extractor run --local",
|
||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/builders/*'",
|
||||
"release": "cliff-jumper"
|
||||
}
|
||||
}
|
190
node_modules/@discordjs/collection/CHANGELOG.md
generated
vendored
Normal file
190
node_modules/@discordjs/collection/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,190 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
# [@discordjs/collection@1.5.3](https://github.com/discordjs/discord.js/compare/@discordjs/collection@1.5.2...@discordjs/collection@1.5.3) - (2023-08-17)
|
||||
|
||||
## Documentation
|
||||
|
||||
- Update Node.js requirement to 16.11.0 (#9764) ([188877c](https://github.com/discordjs/discord.js/commit/188877c50af70f0d5cffb246620fa277435c6ce6))
|
||||
|
||||
# [@discordjs/collection@1.5.2](https://github.com/discordjs/discord.js/compare/@discordjs/collection@1.5.1...@discordjs/collection@1.5.2) - (2023-07-31)
|
||||
|
||||
## Refactor
|
||||
|
||||
- **collection:** Reduce `reduce`'s code (#9581) ([b85a3f2](https://github.com/discordjs/discord.js/commit/b85a3f2ddee8fc5974749b95fc07389a03093df2))
|
||||
|
||||
# [@discordjs/collection@1.5.1](https://github.com/discordjs/discord.js/compare/@discordjs/collection@1.5.0...@discordjs/collection@1.5.1) - (2023-05-01)
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
- Fix external links (#9313) ([a7425c2](https://github.com/discordjs/discord.js/commit/a7425c29c4f23f1b31f4c6a463107ca9eb7fd7e2))
|
||||
|
||||
## Documentation
|
||||
|
||||
- Generate static imports for types with api-extractor ([98a76db](https://github.com/discordjs/discord.js/commit/98a76db482879f79d6bb2fb2e5fc65ac2c34e2d9))
|
||||
|
||||
# [@discordjs/collection@1.5.2](https://github.com/discordjs/discord.js/compare/@discordjs/collection@1.5.1...@discordjs/collection@1.5.2) - (2023-07-31)
|
||||
|
||||
## Refactor
|
||||
|
||||
- **collection:** Reduce `reduce`'s code (#9581) ([b85a3f2](https://github.com/discordjs/discord.js/commit/b85a3f2ddee8fc5974749b95fc07389a03093df2))
|
||||
|
||||
# [@discordjs/collection@1.5.1](https://github.com/discordjs/discord.js/compare/@discordjs/collection@1.5.0...@discordjs/collection@1.5.1) - (2023-05-01)
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
- Fix external links (#9313) ([a7425c2](https://github.com/discordjs/discord.js/commit/a7425c29c4f23f1b31f4c6a463107ca9eb7fd7e2))
|
||||
|
||||
## Documentation
|
||||
|
||||
- Generate static imports for types with api-extractor ([98a76db](https://github.com/discordjs/discord.js/commit/98a76db482879f79d6bb2fb2e5fc65ac2c34e2d9))
|
||||
|
||||
# [@discordjs/collection@1.5.1](https://github.com/discordjs/discord.js/compare/@discordjs/collection@1.5.0...@discordjs/collection@1.5.1) - (2023-05-01)
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
- Fix external links (#9313) ([a7425c2](https://github.com/discordjs/discord.js/commit/a7425c29c4f23f1b31f4c6a463107ca9eb7fd7e2))
|
||||
|
||||
## Documentation
|
||||
|
||||
- Generate static imports for types with api-extractor ([98a76db](https://github.com/discordjs/discord.js/commit/98a76db482879f79d6bb2fb2e5fc65ac2c34e2d9))
|
||||
|
||||
# [@discordjs/collection@1.5.0](https://github.com/discordjs/discord.js/compare/@discordjs/collection@1.4.0...@discordjs/collection@1.5.0) - (2023-04-01)
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
- **scripts:** Accessing tsComment ([d8d5f31](https://github.com/discordjs/discord.js/commit/d8d5f31d3927fd1de62f1fa3a1a6e454243ad87b))
|
||||
|
||||
## Features
|
||||
|
||||
- **website:** Render syntax and mdx on the server (#9086) ([ee5169e](https://github.com/discordjs/discord.js/commit/ee5169e0aadd7bbfcd752aae614ec0f69602b68b))
|
||||
|
||||
## Refactor
|
||||
|
||||
- **collection:** Fix/silence linter warnings (#9266) ([d6f4e60](https://github.com/discordjs/discord.js/commit/d6f4e60efd1a1796fc84dbbfbac4f9790e480a1c))
|
||||
|
||||
# [@discordjs/collection@1.4.0](https://github.com/discordjs/discord.js/compare/@discordjs/collection@1.3.0...@discordjs/collection@1.4.0) - (2023-03-12)
|
||||
|
||||
## Documentation
|
||||
|
||||
- Fix version export (#9049) ([8b70f49](https://github.com/discordjs/discord.js/commit/8b70f497a1207e30edebdecd12b926c981c13d28))
|
||||
|
||||
## Features
|
||||
|
||||
- **website:** Add support for source file links (#9048) ([f6506e9](https://github.com/discordjs/discord.js/commit/f6506e99c496683ee0ab67db0726b105b929af38))
|
||||
|
||||
## Refactor
|
||||
|
||||
- Compare with `undefined` directly (#9191) ([869153c](https://github.com/discordjs/discord.js/commit/869153c3fdf155783e7c0ecebd3627b087c3a026))
|
||||
|
||||
# [@discordjs/collection@1.3.0](https://github.com/discordjs/discord.js/compare/@discordjs/collection@1.2.0...@discordjs/collection@1.3.0) - (2022-11-28)
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
- Pin @types/node version ([9d8179c](https://github.com/discordjs/discord.js/commit/9d8179c6a78e1c7f9976f852804055964d5385d4))
|
||||
|
||||
## Features
|
||||
|
||||
- Add `Collection#subtract()` (#8393) ([291f36c](https://github.com/discordjs/discord.js/commit/291f36cd736b5dea058145a1335bf7c78ec1d81d))
|
||||
|
||||
# [@discordjs/collection@1.2.0](https://github.com/discordjs/discord.js/compare/@discordjs/collection@1.1.0...@discordjs/collection@1.2.0) - (2022-10-08)
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
- Footer / sidebar / deprecation alert ([ba3e0ed](https://github.com/discordjs/discord.js/commit/ba3e0ed348258fe8e51eefb4aa7379a1230616a9))
|
||||
|
||||
## Documentation
|
||||
|
||||
- Change name (#8604) ([dd5a089](https://github.com/discordjs/discord.js/commit/dd5a08944c258a847fc4377f1d5e953264ab47d0))
|
||||
- Remove xml tag from collection#find (#8550) ([4032457](https://github.com/discordjs/discord.js/commit/40324574ebea9894cadcc967e0db0e4e21d62768))
|
||||
|
||||
## Features
|
||||
|
||||
- Web-components (#8715) ([0ac3e76](https://github.com/discordjs/discord.js/commit/0ac3e766bd9dbdeb106483fa4bb085d74de346a2))
|
||||
|
||||
## Refactor
|
||||
|
||||
- Website components (#8600) ([c334157](https://github.com/discordjs/discord.js/commit/c3341570d983aea9ecc419979d5a01de658c9d67))
|
||||
- Use `eslint-config-neon` for packages. (#8579) ([edadb9f](https://github.com/discordjs/discord.js/commit/edadb9fe5dfd9ff51a3cfc9b25cb242d3f9f5241))
|
||||
|
||||
## Typings
|
||||
|
||||
- **Collection:** Make fn return type unknown (#8676) ([822b7f2](https://github.com/discordjs/discord.js/commit/822b7f234af053c8f917b0a998b82abfccd33801))
|
||||
|
||||
# [@discordjs/collection@1.1.0](https://github.com/discordjs/discord.js/compare/@discordjs/collection@1.0.1...@discordjs/collection@1.1.0) - (2022-08-22)
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
- Use proper format for `@link` text (#8384) ([2655639](https://github.com/discordjs/discord.js/commit/26556390a3800e954974a00c1328ff47d3e67e9a))
|
||||
|
||||
## Documentation
|
||||
|
||||
- Fence examples in codeblocks ([193b252](https://github.com/discordjs/discord.js/commit/193b252672440a860318d3c2968aedd9cb88e0ce))
|
||||
- Use link tags (#8382) ([5494791](https://github.com/discordjs/discord.js/commit/549479131318c659f86f0eb18578d597e22522d3))
|
||||
|
||||
## Features
|
||||
|
||||
- **website:** Show `constructor` information (#8540) ([e42fd16](https://github.com/discordjs/discord.js/commit/e42fd1636973b10dd7ed6fb4280ee1a4a8f82007))
|
||||
- **website:** Show descriptions for `@typeParam` blocks (#8523) ([e475b63](https://github.com/discordjs/discord.js/commit/e475b63f257f6261d73cb89fee9ecbcdd84e2a6b))
|
||||
|
||||
## Refactor
|
||||
|
||||
- **website:** Adjust typography (#8503) ([0f83402](https://github.com/discordjs/discord.js/commit/0f834029850d2448981596cf082ff59917018d66))
|
||||
- Docs design (#8487) ([4ab1d09](https://github.com/discordjs/discord.js/commit/4ab1d09997a18879a9eb9bda39df6f15aa22557e))
|
||||
|
||||
# [@discordjs/collection@0.8.0](https://github.com/discordjs/discord.js/compare/@discordjs/collection@0.7.0...@discordjs/collection@0.8.0) - (2022-07-17)
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
- **Collection:** Make error messages consistent (#8224) ([5bd6b28](https://github.com/discordjs/discord.js/commit/5bd6b28b3ebfced1cb9d23e83bd7c0def7a12404))
|
||||
- Check for function type (#8064) ([3bb9c0e](https://github.com/discordjs/discord.js/commit/3bb9c0e5c37311044ff41761b572ac4f91cda57c))
|
||||
|
||||
## Documentation
|
||||
|
||||
- Add codecov coverage badge to readmes (#8226) ([f6db285](https://github.com/discordjs/discord.js/commit/f6db285c073898a749fe4591cbd4463d1896daf5))
|
||||
|
||||
## Features
|
||||
|
||||
- Codecov (#8219) ([f10f4cd](https://github.com/discordjs/discord.js/commit/f10f4cdcd88ca6be7ec735ed3a415ba13da83db0))
|
||||
- **docgen:** Update typedoc ([b3346f4](https://github.com/discordjs/discord.js/commit/b3346f4b9b3d4f96443506643d4631dc1c6d7b21))
|
||||
- Website (#8043) ([127931d](https://github.com/discordjs/discord.js/commit/127931d1df7a2a5c27923c2f2151dbf3824e50cc))
|
||||
- **docgen:** Typescript support ([3279b40](https://github.com/discordjs/discord.js/commit/3279b40912e6aa61507bedb7db15a2b8668de44b))
|
||||
- Docgen package (#8029) ([8b979c0](https://github.com/discordjs/discord.js/commit/8b979c0245c42fd824d8e98745ee869f5360fc86))
|
||||
- Use vitest instead of jest for more speed ([8d8e6c0](https://github.com/discordjs/discord.js/commit/8d8e6c03decd7352a2aa180f6e5bc1a13602539b))
|
||||
- Add scripts package for locally used scripts ([f2ae1f9](https://github.com/discordjs/discord.js/commit/f2ae1f9348bfd893332a9060f71a8a5f272a1b8b))
|
||||
|
||||
## Refactor
|
||||
|
||||
- **collection:** Remove `default` property (#8055) ([c8f1690](https://github.com/discordjs/discord.js/commit/c8f1690896f55f06e05a83704262783cfc2bb91d))
|
||||
- **collection:** Remove default export (#8053) ([16810f3](https://github.com/discordjs/discord.js/commit/16810f3e410bf35ed7e6e7412d517ea74c792c5d))
|
||||
- Move all the config files to root (#8033) ([769ea0b](https://github.com/discordjs/discord.js/commit/769ea0bfe78c4f1d413c6b397c604ffe91e39c6a))
|
||||
|
||||
## Testing
|
||||
|
||||
- **collection:** Improve coverage (#8222) ([a51f721](https://github.com/discordjs/discord.js/commit/a51f7215eca67a0f46fba8b2d706f7ec6f6dc228))
|
||||
|
||||
# [@discordjs/collection@0.7.0](https://github.com/discordjs/discord.js/compare/@discordjs/collection@0.6.0...@discordjs/collection@0.7.0) - (2022-06-04)
|
||||
|
||||
## Styling
|
||||
|
||||
- Cleanup tests and tsup configs ([6b8ef20](https://github.com/discordjs/discord.js/commit/6b8ef20cb3af5b5cfd176dd0aa0a1a1e98551629))
|
||||
|
||||
# [@discordjs/collection@0.6.0](https://github.com/discordjs/discord.js/compare/@discordjs/collection@0.5.0...@discordjs/collection@0.6.0) - (2022-04-17)
|
||||
|
||||
## Features
|
||||
|
||||
- Add support for module: NodeNext in TS and ESM (#7598) ([8f1986a](https://github.com/discordjs/discord.js/commit/8f1986a6aa98365e09b00e84ad5f9f354ab61f3d))
|
||||
- **builders:** Add attachment command option type (#7203) ([ae0f35f](https://github.com/discordjs/discord.js/commit/ae0f35f51d68dfa5a7dc43d161ef9365171debdb))
|
||||
- **Collection:** Add merging functions (#7299) ([e4bd07b](https://github.com/discordjs/discord.js/commit/e4bd07b2394f227ea06b72eb6999de9ab3127b25))
|
||||
|
||||
# [@discordjs/collection@0.5.0](https://github.com/discordjs/discord.js/compare/@discordjs/collection@0.4.0...@discordjs/collection@0.5.0) - (2022-01-24)
|
||||
|
||||
## Refactor
|
||||
|
||||
- Make `intersect` perform a true intersection (#7211) ([d8efba2](https://github.com/discordjs/discord.js/commit/d8efba24e09aa2a8dbf028fc57a561a56e7833fd))
|
||||
|
||||
## Typings
|
||||
|
||||
- Add `ReadonlyCollection` (#7245) ([db25f52](https://github.com/discordjs/discord.js/commit/db25f529b26d7c819c1c42ad3e26c2263ea2da0e))
|
||||
- **Collection:** Union types on `intersect` and `difference` (#7196) ([1f9b922](https://github.com/discordjs/discord.js/commit/1f9b9225f2066e9cc66c3355417139fd25cc403c))
|
191
node_modules/@discordjs/collection/LICENSE
generated
vendored
Normal file
191
node_modules/@discordjs/collection/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,191 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Copyright 2021 Noel Buechler
|
||||
Copyright 2015 Amish Shah
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
67
node_modules/@discordjs/collection/README.md
generated
vendored
Normal file
67
node_modules/@discordjs/collection/README.md
generated
vendored
Normal file
|
@ -0,0 +1,67 @@
|
|||
<div align="center">
|
||||
<br />
|
||||
<p>
|
||||
<a href="https://discord.js.org"><img src="https://discord.js.org/static/logo.svg" width="546" alt="discord.js" /></a>
|
||||
</p>
|
||||
<br />
|
||||
<p>
|
||||
<a href="https://discord.gg/djs"><img src="https://img.shields.io/discord/222078108977594368?color=5865F2&logo=discord&logoColor=white" alt="Discord server" /></a>
|
||||
<a href="https://www.npmjs.com/package/@discordjs/collection"><img src="https://img.shields.io/npm/v/@discordjs/collection.svg?maxAge=3600" alt="npm version" /></a>
|
||||
<a href="https://www.npmjs.com/package/@discordjs/collection"><img src="https://img.shields.io/npm/dt/@discordjs/collection.svg?maxAge=3600" alt="npm downloads" /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Build status" /></a>
|
||||
<a href="https://codecov.io/gh/discordjs/discord.js" ><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2&flag=collection" alt="Code coverage" /></a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
|
||||
<a href="https://www.cloudflare.com"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-workers.png" alt="Cloudflare Workers" height="44" /></a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
## About
|
||||
|
||||
`@discordjs/collection` is a powerful utility data structure used in discord.js.
|
||||
|
||||
## Installation
|
||||
|
||||
**Node.js 16.11.0 or newer is required.**
|
||||
|
||||
```sh
|
||||
npm install @discordjs/collection
|
||||
yarn add @discordjs/collection
|
||||
pnpm add @discordjs/collection
|
||||
```
|
||||
|
||||
## Links
|
||||
|
||||
- [Website][website] ([source][website-source])
|
||||
- [Documentation][documentation]
|
||||
- [Guide][guide] ([source][guide-source])
|
||||
Also see the v13 to v14 [Update Guide][guide-update], which includes updated and removed items from the library.
|
||||
- [discord.js Discord server][discord]
|
||||
- [Discord API Discord server][discord-api]
|
||||
- [GitHub][source]
|
||||
- [npm][npm]
|
||||
- [Related libraries][related-libs]
|
||||
|
||||
## Contributing
|
||||
|
||||
Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the
|
||||
[documentation][documentation].
|
||||
See [the contribution guide][contributing] if you'd like to submit a PR.
|
||||
|
||||
## Help
|
||||
|
||||
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to join our official [discord.js Server][discord].
|
||||
|
||||
[website]: https://discord.js.org
|
||||
[website-source]: https://github.com/discordjs/discord.js/tree/main/apps/website
|
||||
[documentation]: https://discord.js.org/docs/packages/collection/stable
|
||||
[guide]: https://discordjs.guide/
|
||||
[guide-source]: https://github.com/discordjs/guide
|
||||
[guide-update]: https://discordjs.guide/additional-info/changes-in-v14.html
|
||||
[discord]: https://discord.gg/djs
|
||||
[discord-api]: https://discord.gg/discord-api
|
||||
[source]: https://github.com/discordjs/discord.js/tree/main/packages/collection
|
||||
[npm]: https://www.npmjs.com/package/@discordjs/collection
|
||||
[related-libs]: https://discord.com/developers/docs/topics/community-resources#libraries
|
||||
[contributing]: https://github.com/discordjs/discord.js/blob/main/.github/CONTRIBUTING.md
|
457
node_modules/@discordjs/collection/dist/index.d.mts
generated
vendored
Normal file
457
node_modules/@discordjs/collection/dist/index.d.mts
generated
vendored
Normal file
|
@ -0,0 +1,457 @@
|
|||
/**
|
||||
* @internal
|
||||
*/
|
||||
interface CollectionConstructor {
|
||||
new (): Collection<unknown, unknown>;
|
||||
new <K, V>(entries?: readonly (readonly [K, V])[] | null): Collection<K, V>;
|
||||
new <K, V>(iterable: Iterable<readonly [K, V]>): Collection<K, V>;
|
||||
readonly prototype: Collection<unknown, unknown>;
|
||||
readonly [Symbol.species]: CollectionConstructor;
|
||||
}
|
||||
/**
|
||||
* Represents an immutable version of a collection
|
||||
*/
|
||||
type ReadonlyCollection<K, V> = Omit<Collection<K, V>, 'delete' | 'ensure' | 'forEach' | 'get' | 'reverse' | 'set' | 'sort' | 'sweep'> & ReadonlyMap<K, V>;
|
||||
/**
|
||||
* Separate interface for the constructor so that emitted js does not have a constructor that overwrites itself
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface Collection<K, V> extends Map<K, V> {
|
||||
constructor: CollectionConstructor;
|
||||
}
|
||||
/**
|
||||
* A Map with additional utility methods. This is used throughout discord.js rather than Arrays for anything that has
|
||||
* an ID, for significantly improved performance and ease-of-use.
|
||||
*
|
||||
* @typeParam K - The key type this collection holds
|
||||
* @typeParam V - The value type this collection holds
|
||||
*/
|
||||
declare class Collection<K, V> extends Map<K, V> {
|
||||
/**
|
||||
* Obtains the value of the given key if it exists, otherwise sets and returns the value provided by the default value generator.
|
||||
*
|
||||
* @param key - The key to get if it exists, or set otherwise
|
||||
* @param defaultValueGenerator - A function that generates the default value
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.ensure(guildId, () => defaultGuildConfig);
|
||||
* ```
|
||||
*/
|
||||
ensure(key: K, defaultValueGenerator: (key: K, collection: this) => V): V;
|
||||
/**
|
||||
* Checks if all of the elements exist in the collection.
|
||||
*
|
||||
* @param keys - The keys of the elements to check for
|
||||
* @returns `true` if all of the elements exist, `false` if at least one does not exist.
|
||||
*/
|
||||
hasAll(...keys: K[]): boolean;
|
||||
/**
|
||||
* Checks if any of the elements exist in the collection.
|
||||
*
|
||||
* @param keys - The keys of the elements to check for
|
||||
* @returns `true` if any of the elements exist, `false` if none exist.
|
||||
*/
|
||||
hasAny(...keys: K[]): boolean;
|
||||
/**
|
||||
* Obtains the first value(s) in this collection.
|
||||
*
|
||||
* @param amount - Amount of values to obtain from the beginning
|
||||
* @returns A single value if no amount is provided or an array of values, starting from the end if amount is negative
|
||||
*/
|
||||
first(): V | undefined;
|
||||
first(amount: number): V[];
|
||||
/**
|
||||
* Obtains the first key(s) in this collection.
|
||||
*
|
||||
* @param amount - Amount of keys to obtain from the beginning
|
||||
* @returns A single key if no amount is provided or an array of keys, starting from the end if
|
||||
* amount is negative
|
||||
*/
|
||||
firstKey(): K | undefined;
|
||||
firstKey(amount: number): K[];
|
||||
/**
|
||||
* Obtains the last value(s) in this collection.
|
||||
*
|
||||
* @param amount - Amount of values to obtain from the end
|
||||
* @returns A single value if no amount is provided or an array of values, starting from the start if
|
||||
* amount is negative
|
||||
*/
|
||||
last(): V | undefined;
|
||||
last(amount: number): V[];
|
||||
/**
|
||||
* Obtains the last key(s) in this collection.
|
||||
*
|
||||
* @param amount - Amount of keys to obtain from the end
|
||||
* @returns A single key if no amount is provided or an array of keys, starting from the start if
|
||||
* amount is negative
|
||||
*/
|
||||
lastKey(): K | undefined;
|
||||
lastKey(amount: number): K[];
|
||||
/**
|
||||
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.
|
||||
* Returns the item at a given index, allowing for positive and negative integers.
|
||||
* Negative integers count back from the last item in the collection.
|
||||
*
|
||||
* @param index - The index of the element to obtain
|
||||
*/
|
||||
at(index: number): V | undefined;
|
||||
/**
|
||||
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.
|
||||
* Returns the key at a given index, allowing for positive and negative integers.
|
||||
* Negative integers count back from the last item in the collection.
|
||||
*
|
||||
* @param index - The index of the key to obtain
|
||||
*/
|
||||
keyAt(index: number): K | undefined;
|
||||
/**
|
||||
* Obtains unique random value(s) from this collection.
|
||||
*
|
||||
* @param amount - Amount of values to obtain randomly
|
||||
* @returns A single value if no amount is provided or an array of values
|
||||
*/
|
||||
random(): V | undefined;
|
||||
random(amount: number): V[];
|
||||
/**
|
||||
* Obtains unique random key(s) from this collection.
|
||||
*
|
||||
* @param amount - Amount of keys to obtain randomly
|
||||
* @returns A single key if no amount is provided or an array
|
||||
*/
|
||||
randomKey(): K | undefined;
|
||||
randomKey(amount: number): K[];
|
||||
/**
|
||||
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse | Array.reverse()}
|
||||
* but returns a Collection instead of an Array.
|
||||
*/
|
||||
reverse(): this;
|
||||
/**
|
||||
* Searches for a single item where the given function returns a truthy value. This behaves like
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find | Array.find()}.
|
||||
* All collections used in Discord.js are mapped using their `id` property, and if you want to find by id you
|
||||
* should use the `get` method. See
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get | MDN} for details.
|
||||
*
|
||||
* @param fn - The function to test with (should return boolean)
|
||||
* @param thisArg - Value to use as `this` when executing function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.find(user => user.username === 'Bob');
|
||||
* ```
|
||||
*/
|
||||
find<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): V2 | undefined;
|
||||
find(fn: (value: V, key: K, collection: this) => unknown): V | undefined;
|
||||
find<This, V2 extends V>(fn: (this: This, value: V, key: K, collection: this) => value is V2, thisArg: This): V2 | undefined;
|
||||
find<This>(fn: (this: This, value: V, key: K, collection: this) => unknown, thisArg: This): V | undefined;
|
||||
/**
|
||||
* Searches for the key of a single item where the given function returns a truthy value. This behaves like
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex | Array.findIndex()},
|
||||
* but returns the key rather than the positional index.
|
||||
*
|
||||
* @param fn - The function to test with (should return boolean)
|
||||
* @param thisArg - Value to use as `this` when executing function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.findKey(user => user.username === 'Bob');
|
||||
* ```
|
||||
*/
|
||||
findKey<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): K2 | undefined;
|
||||
findKey(fn: (value: V, key: K, collection: this) => unknown): K | undefined;
|
||||
findKey<This, K2 extends K>(fn: (this: This, value: V, key: K, collection: this) => key is K2, thisArg: This): K2 | undefined;
|
||||
findKey<This>(fn: (this: This, value: V, key: K, collection: this) => unknown, thisArg: This): K | undefined;
|
||||
/**
|
||||
* Removes items that satisfy the provided filter function.
|
||||
*
|
||||
* @param fn - Function used to test (should return a boolean)
|
||||
* @param thisArg - Value to use as `this` when executing function
|
||||
* @returns The number of removed entries
|
||||
*/
|
||||
sweep(fn: (value: V, key: K, collection: this) => unknown): number;
|
||||
sweep<T>(fn: (this: T, value: V, key: K, collection: this) => unknown, thisArg: T): number;
|
||||
/**
|
||||
* Identical to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter | Array.filter()},
|
||||
* but returns a Collection instead of an Array.
|
||||
*
|
||||
* @param fn - The function to test with (should return boolean)
|
||||
* @param thisArg - Value to use as `this` when executing function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.filter(user => user.username === 'Bob');
|
||||
* ```
|
||||
*/
|
||||
filter<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): Collection<K2, V>;
|
||||
filter<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): Collection<K, V2>;
|
||||
filter(fn: (value: V, key: K, collection: this) => unknown): Collection<K, V>;
|
||||
filter<This, K2 extends K>(fn: (this: This, value: V, key: K, collection: this) => key is K2, thisArg: This): Collection<K2, V>;
|
||||
filter<This, V2 extends V>(fn: (this: This, value: V, key: K, collection: this) => value is V2, thisArg: This): Collection<K, V2>;
|
||||
filter<This>(fn: (this: This, value: V, key: K, collection: this) => unknown, thisArg: This): Collection<K, V>;
|
||||
/**
|
||||
* Partitions the collection into two collections where the first collection
|
||||
* contains the items that passed and the second contains the items that failed.
|
||||
*
|
||||
* @param fn - Function used to test (should return a boolean)
|
||||
* @param thisArg - Value to use as `this` when executing function
|
||||
* @example
|
||||
* ```ts
|
||||
* const [big, small] = collection.partition(guild => guild.memberCount > 250);
|
||||
* ```
|
||||
*/
|
||||
partition<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): [Collection<K2, V>, Collection<Exclude<K, K2>, V>];
|
||||
partition<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): [Collection<K, V2>, Collection<K, Exclude<V, V2>>];
|
||||
partition(fn: (value: V, key: K, collection: this) => unknown): [Collection<K, V>, Collection<K, V>];
|
||||
partition<This, K2 extends K>(fn: (this: This, value: V, key: K, collection: this) => key is K2, thisArg: This): [Collection<K2, V>, Collection<Exclude<K, K2>, V>];
|
||||
partition<This, V2 extends V>(fn: (this: This, value: V, key: K, collection: this) => value is V2, thisArg: This): [Collection<K, V2>, Collection<K, Exclude<V, V2>>];
|
||||
partition<This>(fn: (this: This, value: V, key: K, collection: this) => unknown, thisArg: This): [Collection<K, V>, Collection<K, V>];
|
||||
/**
|
||||
* Maps each item into a Collection, then joins the results into a single Collection. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap | Array.flatMap()}.
|
||||
*
|
||||
* @param fn - Function that produces a new Collection
|
||||
* @param thisArg - Value to use as `this` when executing function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.flatMap(guild => guild.members.cache);
|
||||
* ```
|
||||
*/
|
||||
flatMap<T>(fn: (value: V, key: K, collection: this) => Collection<K, T>): Collection<K, T>;
|
||||
flatMap<T, This>(fn: (this: This, value: V, key: K, collection: this) => Collection<K, T>, thisArg: This): Collection<K, T>;
|
||||
/**
|
||||
* Maps each item to another value into an array. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}.
|
||||
*
|
||||
* @param fn - Function that produces an element of the new array, taking three arguments
|
||||
* @param thisArg - Value to use as `this` when executing function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.map(user => user.tag);
|
||||
* ```
|
||||
*/
|
||||
map<T>(fn: (value: V, key: K, collection: this) => T): T[];
|
||||
map<This, T>(fn: (this: This, value: V, key: K, collection: this) => T, thisArg: This): T[];
|
||||
/**
|
||||
* Maps each item to another value into a collection. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}.
|
||||
*
|
||||
* @param fn - Function that produces an element of the new collection, taking three arguments
|
||||
* @param thisArg - Value to use as `this` when executing function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.mapValues(user => user.tag);
|
||||
* ```
|
||||
*/
|
||||
mapValues<T>(fn: (value: V, key: K, collection: this) => T): Collection<K, T>;
|
||||
mapValues<This, T>(fn: (this: This, value: V, key: K, collection: this) => T, thisArg: This): Collection<K, T>;
|
||||
/**
|
||||
* Checks if there exists an item that passes a test. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some | Array.some()}.
|
||||
*
|
||||
* @param fn - Function used to test (should return a boolean)
|
||||
* @param thisArg - Value to use as `this` when executing function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.some(user => user.discriminator === '0000');
|
||||
* ```
|
||||
*/
|
||||
some(fn: (value: V, key: K, collection: this) => unknown): boolean;
|
||||
some<T>(fn: (this: T, value: V, key: K, collection: this) => unknown, thisArg: T): boolean;
|
||||
/**
|
||||
* Checks if all items passes a test. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every | Array.every()}.
|
||||
*
|
||||
* @param fn - Function used to test (should return a boolean)
|
||||
* @param thisArg - Value to use as `this` when executing function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.every(user => !user.bot);
|
||||
* ```
|
||||
*/
|
||||
every<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): this is Collection<K2, V>;
|
||||
every<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): this is Collection<K, V2>;
|
||||
every(fn: (value: V, key: K, collection: this) => unknown): boolean;
|
||||
every<This, K2 extends K>(fn: (this: This, value: V, key: K, collection: this) => key is K2, thisArg: This): this is Collection<K2, V>;
|
||||
every<This, V2 extends V>(fn: (this: This, value: V, key: K, collection: this) => value is V2, thisArg: This): this is Collection<K, V2>;
|
||||
every<This>(fn: (this: This, value: V, key: K, collection: this) => unknown, thisArg: This): boolean;
|
||||
/**
|
||||
* Applies a function to produce a single value. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce | Array.reduce()}.
|
||||
*
|
||||
* @param fn - Function used to reduce, taking four arguments; `accumulator`, `currentValue`, `currentKey`,
|
||||
* and `collection`
|
||||
* @param initialValue - Starting value for the accumulator
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.reduce((acc, guild) => acc + guild.memberCount, 0);
|
||||
* ```
|
||||
*/
|
||||
reduce<T = V>(fn: (accumulator: T, value: V, key: K, collection: this) => T, initialValue?: T): T;
|
||||
/**
|
||||
* Identical to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach | Map.forEach()},
|
||||
* but returns the collection instead of undefined.
|
||||
*
|
||||
* @param fn - Function to execute for each element
|
||||
* @param thisArg - Value to use as `this` when executing function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection
|
||||
* .each(user => console.log(user.username))
|
||||
* .filter(user => user.bot)
|
||||
* .each(user => console.log(user.username));
|
||||
* ```
|
||||
*/
|
||||
each(fn: (value: V, key: K, collection: this) => void): this;
|
||||
each<T>(fn: (this: T, value: V, key: K, collection: this) => void, thisArg: T): this;
|
||||
/**
|
||||
* Runs a function on the collection and returns the collection.
|
||||
*
|
||||
* @param fn - Function to execute
|
||||
* @param thisArg - Value to use as `this` when executing function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection
|
||||
* .tap(coll => console.log(coll.size))
|
||||
* .filter(user => user.bot)
|
||||
* .tap(coll => console.log(coll.size))
|
||||
* ```
|
||||
*/
|
||||
tap(fn: (collection: this) => void): this;
|
||||
tap<T>(fn: (this: T, collection: this) => void, thisArg: T): this;
|
||||
/**
|
||||
* Creates an identical shallow copy of this collection.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const newColl = someColl.clone();
|
||||
* ```
|
||||
*/
|
||||
clone(): Collection<K, V>;
|
||||
/**
|
||||
* Combines this collection with others into a new collection. None of the source collections are modified.
|
||||
*
|
||||
* @param collections - Collections to merge
|
||||
* @example
|
||||
* ```ts
|
||||
* const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);
|
||||
* ```
|
||||
*/
|
||||
concat(...collections: ReadonlyCollection<K, V>[]): Collection<K, V>;
|
||||
/**
|
||||
* Checks if this collection shares identical items with another.
|
||||
* This is different to checking for equality using equal-signs, because
|
||||
* the collections may be different objects, but contain the same data.
|
||||
*
|
||||
* @param collection - Collection to compare with
|
||||
* @returns Whether the collections have identical contents
|
||||
*/
|
||||
equals(collection: ReadonlyCollection<K, V>): boolean;
|
||||
/**
|
||||
* The sort method sorts the items of a collection in place and returns it.
|
||||
* The sort is not necessarily stable in Node 10 or older.
|
||||
* The default sort order is according to string Unicode code points.
|
||||
*
|
||||
* @param compareFunction - Specifies a function that defines the sort order.
|
||||
* If omitted, the collection is sorted according to each character's Unicode code point value, according to the string conversion of each element.
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.sort((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
||||
* ```
|
||||
*/
|
||||
sort(compareFunction?: Comparator<K, V>): this;
|
||||
/**
|
||||
* The intersect method returns a new structure containing items where the keys and values are present in both original structures.
|
||||
*
|
||||
* @param other - The other Collection to filter against
|
||||
*/
|
||||
intersect<T>(other: ReadonlyCollection<K, T>): Collection<K, T>;
|
||||
/**
|
||||
* The subtract method returns a new structure containing items where the keys and values of the original structure are not present in the other.
|
||||
*
|
||||
* @param other - The other Collection to filter against
|
||||
*/
|
||||
subtract<T>(other: ReadonlyCollection<K, T>): Collection<K, V>;
|
||||
/**
|
||||
* The difference method returns a new structure containing items where the key is present in one of the original structures but not the other.
|
||||
*
|
||||
* @param other - The other Collection to filter against
|
||||
*/
|
||||
difference<T>(other: ReadonlyCollection<K, T>): Collection<K, T | V>;
|
||||
/**
|
||||
* Merges two Collections together into a new Collection.
|
||||
*
|
||||
* @param other - The other Collection to merge with
|
||||
* @param whenInSelf - Function getting the result if the entry only exists in this Collection
|
||||
* @param whenInOther - Function getting the result if the entry only exists in the other Collection
|
||||
* @param whenInBoth - Function getting the result if the entry exists in both Collections
|
||||
* @example
|
||||
* ```ts
|
||||
* // Sums up the entries in two collections.
|
||||
* coll.merge(
|
||||
* other,
|
||||
* x => ({ keep: true, value: x }),
|
||||
* y => ({ keep: true, value: y }),
|
||||
* (x, y) => ({ keep: true, value: x + y }),
|
||||
* );
|
||||
* ```
|
||||
* @example
|
||||
* ```ts
|
||||
* // Intersects two collections in a left-biased manner.
|
||||
* coll.merge(
|
||||
* other,
|
||||
* x => ({ keep: false }),
|
||||
* y => ({ keep: false }),
|
||||
* (x, _) => ({ keep: true, value: x }),
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
merge<T, R>(other: ReadonlyCollection<K, T>, whenInSelf: (value: V, key: K) => Keep<R>, whenInOther: (valueOther: T, key: K) => Keep<R>, whenInBoth: (value: V, valueOther: T, key: K) => Keep<R>): Collection<K, R>;
|
||||
/**
|
||||
* The sorted method sorts the items of a collection and returns it.
|
||||
* The sort is not necessarily stable in Node 10 or older.
|
||||
* The default sort order is according to string Unicode code points.
|
||||
*
|
||||
* @param compareFunction - Specifies a function that defines the sort order.
|
||||
* If omitted, the collection is sorted according to each character's Unicode code point value,
|
||||
* according to the string conversion of each element.
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.sorted((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
||||
* ```
|
||||
*/
|
||||
sorted(compareFunction?: Comparator<K, V>): Collection<K, V>;
|
||||
toJSON(): V[];
|
||||
private static defaultSort;
|
||||
/**
|
||||
* Creates a Collection from a list of entries.
|
||||
*
|
||||
* @param entries - The list of entries
|
||||
* @param combine - Function to combine an existing entry with a new one
|
||||
* @example
|
||||
* ```ts
|
||||
* Collection.combineEntries([["a", 1], ["b", 2], ["a", 2]], (x, y) => x + y);
|
||||
* // returns Collection { "a" => 3, "b" => 2 }
|
||||
* ```
|
||||
*/
|
||||
static combineEntries<K, V>(entries: Iterable<[K, V]>, combine: (firstValue: V, secondValue: V, key: K) => V): Collection<K, V>;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type Keep<V> = {
|
||||
keep: false;
|
||||
} | {
|
||||
keep: true;
|
||||
value: V;
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type Comparator<K, V> = (firstValue: V, secondValue: V, firstKey: K, secondKey: K) => number;
|
||||
|
||||
/**
|
||||
* The {@link https://github.com/discordjs/discord.js/blob/main/packages/collection/#readme | @discordjs/collection} version
|
||||
* that you are currently using.
|
||||
*/
|
||||
declare const version: string;
|
||||
|
||||
export { Collection, CollectionConstructor, Comparator, Keep, ReadonlyCollection, version };
|
457
node_modules/@discordjs/collection/dist/index.d.ts
generated
vendored
Normal file
457
node_modules/@discordjs/collection/dist/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,457 @@
|
|||
/**
|
||||
* @internal
|
||||
*/
|
||||
interface CollectionConstructor {
|
||||
new (): Collection<unknown, unknown>;
|
||||
new <K, V>(entries?: readonly (readonly [K, V])[] | null): Collection<K, V>;
|
||||
new <K, V>(iterable: Iterable<readonly [K, V]>): Collection<K, V>;
|
||||
readonly prototype: Collection<unknown, unknown>;
|
||||
readonly [Symbol.species]: CollectionConstructor;
|
||||
}
|
||||
/**
|
||||
* Represents an immutable version of a collection
|
||||
*/
|
||||
type ReadonlyCollection<K, V> = Omit<Collection<K, V>, 'delete' | 'ensure' | 'forEach' | 'get' | 'reverse' | 'set' | 'sort' | 'sweep'> & ReadonlyMap<K, V>;
|
||||
/**
|
||||
* Separate interface for the constructor so that emitted js does not have a constructor that overwrites itself
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface Collection<K, V> extends Map<K, V> {
|
||||
constructor: CollectionConstructor;
|
||||
}
|
||||
/**
|
||||
* A Map with additional utility methods. This is used throughout discord.js rather than Arrays for anything that has
|
||||
* an ID, for significantly improved performance and ease-of-use.
|
||||
*
|
||||
* @typeParam K - The key type this collection holds
|
||||
* @typeParam V - The value type this collection holds
|
||||
*/
|
||||
declare class Collection<K, V> extends Map<K, V> {
|
||||
/**
|
||||
* Obtains the value of the given key if it exists, otherwise sets and returns the value provided by the default value generator.
|
||||
*
|
||||
* @param key - The key to get if it exists, or set otherwise
|
||||
* @param defaultValueGenerator - A function that generates the default value
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.ensure(guildId, () => defaultGuildConfig);
|
||||
* ```
|
||||
*/
|
||||
ensure(key: K, defaultValueGenerator: (key: K, collection: this) => V): V;
|
||||
/**
|
||||
* Checks if all of the elements exist in the collection.
|
||||
*
|
||||
* @param keys - The keys of the elements to check for
|
||||
* @returns `true` if all of the elements exist, `false` if at least one does not exist.
|
||||
*/
|
||||
hasAll(...keys: K[]): boolean;
|
||||
/**
|
||||
* Checks if any of the elements exist in the collection.
|
||||
*
|
||||
* @param keys - The keys of the elements to check for
|
||||
* @returns `true` if any of the elements exist, `false` if none exist.
|
||||
*/
|
||||
hasAny(...keys: K[]): boolean;
|
||||
/**
|
||||
* Obtains the first value(s) in this collection.
|
||||
*
|
||||
* @param amount - Amount of values to obtain from the beginning
|
||||
* @returns A single value if no amount is provided or an array of values, starting from the end if amount is negative
|
||||
*/
|
||||
first(): V | undefined;
|
||||
first(amount: number): V[];
|
||||
/**
|
||||
* Obtains the first key(s) in this collection.
|
||||
*
|
||||
* @param amount - Amount of keys to obtain from the beginning
|
||||
* @returns A single key if no amount is provided or an array of keys, starting from the end if
|
||||
* amount is negative
|
||||
*/
|
||||
firstKey(): K | undefined;
|
||||
firstKey(amount: number): K[];
|
||||
/**
|
||||
* Obtains the last value(s) in this collection.
|
||||
*
|
||||
* @param amount - Amount of values to obtain from the end
|
||||
* @returns A single value if no amount is provided or an array of values, starting from the start if
|
||||
* amount is negative
|
||||
*/
|
||||
last(): V | undefined;
|
||||
last(amount: number): V[];
|
||||
/**
|
||||
* Obtains the last key(s) in this collection.
|
||||
*
|
||||
* @param amount - Amount of keys to obtain from the end
|
||||
* @returns A single key if no amount is provided or an array of keys, starting from the start if
|
||||
* amount is negative
|
||||
*/
|
||||
lastKey(): K | undefined;
|
||||
lastKey(amount: number): K[];
|
||||
/**
|
||||
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.
|
||||
* Returns the item at a given index, allowing for positive and negative integers.
|
||||
* Negative integers count back from the last item in the collection.
|
||||
*
|
||||
* @param index - The index of the element to obtain
|
||||
*/
|
||||
at(index: number): V | undefined;
|
||||
/**
|
||||
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.
|
||||
* Returns the key at a given index, allowing for positive and negative integers.
|
||||
* Negative integers count back from the last item in the collection.
|
||||
*
|
||||
* @param index - The index of the key to obtain
|
||||
*/
|
||||
keyAt(index: number): K | undefined;
|
||||
/**
|
||||
* Obtains unique random value(s) from this collection.
|
||||
*
|
||||
* @param amount - Amount of values to obtain randomly
|
||||
* @returns A single value if no amount is provided or an array of values
|
||||
*/
|
||||
random(): V | undefined;
|
||||
random(amount: number): V[];
|
||||
/**
|
||||
* Obtains unique random key(s) from this collection.
|
||||
*
|
||||
* @param amount - Amount of keys to obtain randomly
|
||||
* @returns A single key if no amount is provided or an array
|
||||
*/
|
||||
randomKey(): K | undefined;
|
||||
randomKey(amount: number): K[];
|
||||
/**
|
||||
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse | Array.reverse()}
|
||||
* but returns a Collection instead of an Array.
|
||||
*/
|
||||
reverse(): this;
|
||||
/**
|
||||
* Searches for a single item where the given function returns a truthy value. This behaves like
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find | Array.find()}.
|
||||
* All collections used in Discord.js are mapped using their `id` property, and if you want to find by id you
|
||||
* should use the `get` method. See
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get | MDN} for details.
|
||||
*
|
||||
* @param fn - The function to test with (should return boolean)
|
||||
* @param thisArg - Value to use as `this` when executing function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.find(user => user.username === 'Bob');
|
||||
* ```
|
||||
*/
|
||||
find<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): V2 | undefined;
|
||||
find(fn: (value: V, key: K, collection: this) => unknown): V | undefined;
|
||||
find<This, V2 extends V>(fn: (this: This, value: V, key: K, collection: this) => value is V2, thisArg: This): V2 | undefined;
|
||||
find<This>(fn: (this: This, value: V, key: K, collection: this) => unknown, thisArg: This): V | undefined;
|
||||
/**
|
||||
* Searches for the key of a single item where the given function returns a truthy value. This behaves like
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex | Array.findIndex()},
|
||||
* but returns the key rather than the positional index.
|
||||
*
|
||||
* @param fn - The function to test with (should return boolean)
|
||||
* @param thisArg - Value to use as `this` when executing function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.findKey(user => user.username === 'Bob');
|
||||
* ```
|
||||
*/
|
||||
findKey<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): K2 | undefined;
|
||||
findKey(fn: (value: V, key: K, collection: this) => unknown): K | undefined;
|
||||
findKey<This, K2 extends K>(fn: (this: This, value: V, key: K, collection: this) => key is K2, thisArg: This): K2 | undefined;
|
||||
findKey<This>(fn: (this: This, value: V, key: K, collection: this) => unknown, thisArg: This): K | undefined;
|
||||
/**
|
||||
* Removes items that satisfy the provided filter function.
|
||||
*
|
||||
* @param fn - Function used to test (should return a boolean)
|
||||
* @param thisArg - Value to use as `this` when executing function
|
||||
* @returns The number of removed entries
|
||||
*/
|
||||
sweep(fn: (value: V, key: K, collection: this) => unknown): number;
|
||||
sweep<T>(fn: (this: T, value: V, key: K, collection: this) => unknown, thisArg: T): number;
|
||||
/**
|
||||
* Identical to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter | Array.filter()},
|
||||
* but returns a Collection instead of an Array.
|
||||
*
|
||||
* @param fn - The function to test with (should return boolean)
|
||||
* @param thisArg - Value to use as `this` when executing function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.filter(user => user.username === 'Bob');
|
||||
* ```
|
||||
*/
|
||||
filter<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): Collection<K2, V>;
|
||||
filter<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): Collection<K, V2>;
|
||||
filter(fn: (value: V, key: K, collection: this) => unknown): Collection<K, V>;
|
||||
filter<This, K2 extends K>(fn: (this: This, value: V, key: K, collection: this) => key is K2, thisArg: This): Collection<K2, V>;
|
||||
filter<This, V2 extends V>(fn: (this: This, value: V, key: K, collection: this) => value is V2, thisArg: This): Collection<K, V2>;
|
||||
filter<This>(fn: (this: This, value: V, key: K, collection: this) => unknown, thisArg: This): Collection<K, V>;
|
||||
/**
|
||||
* Partitions the collection into two collections where the first collection
|
||||
* contains the items that passed and the second contains the items that failed.
|
||||
*
|
||||
* @param fn - Function used to test (should return a boolean)
|
||||
* @param thisArg - Value to use as `this` when executing function
|
||||
* @example
|
||||
* ```ts
|
||||
* const [big, small] = collection.partition(guild => guild.memberCount > 250);
|
||||
* ```
|
||||
*/
|
||||
partition<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): [Collection<K2, V>, Collection<Exclude<K, K2>, V>];
|
||||
partition<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): [Collection<K, V2>, Collection<K, Exclude<V, V2>>];
|
||||
partition(fn: (value: V, key: K, collection: this) => unknown): [Collection<K, V>, Collection<K, V>];
|
||||
partition<This, K2 extends K>(fn: (this: This, value: V, key: K, collection: this) => key is K2, thisArg: This): [Collection<K2, V>, Collection<Exclude<K, K2>, V>];
|
||||
partition<This, V2 extends V>(fn: (this: This, value: V, key: K, collection: this) => value is V2, thisArg: This): [Collection<K, V2>, Collection<K, Exclude<V, V2>>];
|
||||
partition<This>(fn: (this: This, value: V, key: K, collection: this) => unknown, thisArg: This): [Collection<K, V>, Collection<K, V>];
|
||||
/**
|
||||
* Maps each item into a Collection, then joins the results into a single Collection. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap | Array.flatMap()}.
|
||||
*
|
||||
* @param fn - Function that produces a new Collection
|
||||
* @param thisArg - Value to use as `this` when executing function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.flatMap(guild => guild.members.cache);
|
||||
* ```
|
||||
*/
|
||||
flatMap<T>(fn: (value: V, key: K, collection: this) => Collection<K, T>): Collection<K, T>;
|
||||
flatMap<T, This>(fn: (this: This, value: V, key: K, collection: this) => Collection<K, T>, thisArg: This): Collection<K, T>;
|
||||
/**
|
||||
* Maps each item to another value into an array. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}.
|
||||
*
|
||||
* @param fn - Function that produces an element of the new array, taking three arguments
|
||||
* @param thisArg - Value to use as `this` when executing function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.map(user => user.tag);
|
||||
* ```
|
||||
*/
|
||||
map<T>(fn: (value: V, key: K, collection: this) => T): T[];
|
||||
map<This, T>(fn: (this: This, value: V, key: K, collection: this) => T, thisArg: This): T[];
|
||||
/**
|
||||
* Maps each item to another value into a collection. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}.
|
||||
*
|
||||
* @param fn - Function that produces an element of the new collection, taking three arguments
|
||||
* @param thisArg - Value to use as `this` when executing function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.mapValues(user => user.tag);
|
||||
* ```
|
||||
*/
|
||||
mapValues<T>(fn: (value: V, key: K, collection: this) => T): Collection<K, T>;
|
||||
mapValues<This, T>(fn: (this: This, value: V, key: K, collection: this) => T, thisArg: This): Collection<K, T>;
|
||||
/**
|
||||
* Checks if there exists an item that passes a test. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some | Array.some()}.
|
||||
*
|
||||
* @param fn - Function used to test (should return a boolean)
|
||||
* @param thisArg - Value to use as `this` when executing function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.some(user => user.discriminator === '0000');
|
||||
* ```
|
||||
*/
|
||||
some(fn: (value: V, key: K, collection: this) => unknown): boolean;
|
||||
some<T>(fn: (this: T, value: V, key: K, collection: this) => unknown, thisArg: T): boolean;
|
||||
/**
|
||||
* Checks if all items passes a test. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every | Array.every()}.
|
||||
*
|
||||
* @param fn - Function used to test (should return a boolean)
|
||||
* @param thisArg - Value to use as `this` when executing function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.every(user => !user.bot);
|
||||
* ```
|
||||
*/
|
||||
every<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): this is Collection<K2, V>;
|
||||
every<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): this is Collection<K, V2>;
|
||||
every(fn: (value: V, key: K, collection: this) => unknown): boolean;
|
||||
every<This, K2 extends K>(fn: (this: This, value: V, key: K, collection: this) => key is K2, thisArg: This): this is Collection<K2, V>;
|
||||
every<This, V2 extends V>(fn: (this: This, value: V, key: K, collection: this) => value is V2, thisArg: This): this is Collection<K, V2>;
|
||||
every<This>(fn: (this: This, value: V, key: K, collection: this) => unknown, thisArg: This): boolean;
|
||||
/**
|
||||
* Applies a function to produce a single value. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce | Array.reduce()}.
|
||||
*
|
||||
* @param fn - Function used to reduce, taking four arguments; `accumulator`, `currentValue`, `currentKey`,
|
||||
* and `collection`
|
||||
* @param initialValue - Starting value for the accumulator
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.reduce((acc, guild) => acc + guild.memberCount, 0);
|
||||
* ```
|
||||
*/
|
||||
reduce<T = V>(fn: (accumulator: T, value: V, key: K, collection: this) => T, initialValue?: T): T;
|
||||
/**
|
||||
* Identical to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach | Map.forEach()},
|
||||
* but returns the collection instead of undefined.
|
||||
*
|
||||
* @param fn - Function to execute for each element
|
||||
* @param thisArg - Value to use as `this` when executing function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection
|
||||
* .each(user => console.log(user.username))
|
||||
* .filter(user => user.bot)
|
||||
* .each(user => console.log(user.username));
|
||||
* ```
|
||||
*/
|
||||
each(fn: (value: V, key: K, collection: this) => void): this;
|
||||
each<T>(fn: (this: T, value: V, key: K, collection: this) => void, thisArg: T): this;
|
||||
/**
|
||||
* Runs a function on the collection and returns the collection.
|
||||
*
|
||||
* @param fn - Function to execute
|
||||
* @param thisArg - Value to use as `this` when executing function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection
|
||||
* .tap(coll => console.log(coll.size))
|
||||
* .filter(user => user.bot)
|
||||
* .tap(coll => console.log(coll.size))
|
||||
* ```
|
||||
*/
|
||||
tap(fn: (collection: this) => void): this;
|
||||
tap<T>(fn: (this: T, collection: this) => void, thisArg: T): this;
|
||||
/**
|
||||
* Creates an identical shallow copy of this collection.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const newColl = someColl.clone();
|
||||
* ```
|
||||
*/
|
||||
clone(): Collection<K, V>;
|
||||
/**
|
||||
* Combines this collection with others into a new collection. None of the source collections are modified.
|
||||
*
|
||||
* @param collections - Collections to merge
|
||||
* @example
|
||||
* ```ts
|
||||
* const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);
|
||||
* ```
|
||||
*/
|
||||
concat(...collections: ReadonlyCollection<K, V>[]): Collection<K, V>;
|
||||
/**
|
||||
* Checks if this collection shares identical items with another.
|
||||
* This is different to checking for equality using equal-signs, because
|
||||
* the collections may be different objects, but contain the same data.
|
||||
*
|
||||
* @param collection - Collection to compare with
|
||||
* @returns Whether the collections have identical contents
|
||||
*/
|
||||
equals(collection: ReadonlyCollection<K, V>): boolean;
|
||||
/**
|
||||
* The sort method sorts the items of a collection in place and returns it.
|
||||
* The sort is not necessarily stable in Node 10 or older.
|
||||
* The default sort order is according to string Unicode code points.
|
||||
*
|
||||
* @param compareFunction - Specifies a function that defines the sort order.
|
||||
* If omitted, the collection is sorted according to each character's Unicode code point value, according to the string conversion of each element.
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.sort((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
||||
* ```
|
||||
*/
|
||||
sort(compareFunction?: Comparator<K, V>): this;
|
||||
/**
|
||||
* The intersect method returns a new structure containing items where the keys and values are present in both original structures.
|
||||
*
|
||||
* @param other - The other Collection to filter against
|
||||
*/
|
||||
intersect<T>(other: ReadonlyCollection<K, T>): Collection<K, T>;
|
||||
/**
|
||||
* The subtract method returns a new structure containing items where the keys and values of the original structure are not present in the other.
|
||||
*
|
||||
* @param other - The other Collection to filter against
|
||||
*/
|
||||
subtract<T>(other: ReadonlyCollection<K, T>): Collection<K, V>;
|
||||
/**
|
||||
* The difference method returns a new structure containing items where the key is present in one of the original structures but not the other.
|
||||
*
|
||||
* @param other - The other Collection to filter against
|
||||
*/
|
||||
difference<T>(other: ReadonlyCollection<K, T>): Collection<K, T | V>;
|
||||
/**
|
||||
* Merges two Collections together into a new Collection.
|
||||
*
|
||||
* @param other - The other Collection to merge with
|
||||
* @param whenInSelf - Function getting the result if the entry only exists in this Collection
|
||||
* @param whenInOther - Function getting the result if the entry only exists in the other Collection
|
||||
* @param whenInBoth - Function getting the result if the entry exists in both Collections
|
||||
* @example
|
||||
* ```ts
|
||||
* // Sums up the entries in two collections.
|
||||
* coll.merge(
|
||||
* other,
|
||||
* x => ({ keep: true, value: x }),
|
||||
* y => ({ keep: true, value: y }),
|
||||
* (x, y) => ({ keep: true, value: x + y }),
|
||||
* );
|
||||
* ```
|
||||
* @example
|
||||
* ```ts
|
||||
* // Intersects two collections in a left-biased manner.
|
||||
* coll.merge(
|
||||
* other,
|
||||
* x => ({ keep: false }),
|
||||
* y => ({ keep: false }),
|
||||
* (x, _) => ({ keep: true, value: x }),
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
merge<T, R>(other: ReadonlyCollection<K, T>, whenInSelf: (value: V, key: K) => Keep<R>, whenInOther: (valueOther: T, key: K) => Keep<R>, whenInBoth: (value: V, valueOther: T, key: K) => Keep<R>): Collection<K, R>;
|
||||
/**
|
||||
* The sorted method sorts the items of a collection and returns it.
|
||||
* The sort is not necessarily stable in Node 10 or older.
|
||||
* The default sort order is according to string Unicode code points.
|
||||
*
|
||||
* @param compareFunction - Specifies a function that defines the sort order.
|
||||
* If omitted, the collection is sorted according to each character's Unicode code point value,
|
||||
* according to the string conversion of each element.
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.sorted((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
||||
* ```
|
||||
*/
|
||||
sorted(compareFunction?: Comparator<K, V>): Collection<K, V>;
|
||||
toJSON(): V[];
|
||||
private static defaultSort;
|
||||
/**
|
||||
* Creates a Collection from a list of entries.
|
||||
*
|
||||
* @param entries - The list of entries
|
||||
* @param combine - Function to combine an existing entry with a new one
|
||||
* @example
|
||||
* ```ts
|
||||
* Collection.combineEntries([["a", 1], ["b", 2], ["a", 2]], (x, y) => x + y);
|
||||
* // returns Collection { "a" => 3, "b" => 2 }
|
||||
* ```
|
||||
*/
|
||||
static combineEntries<K, V>(entries: Iterable<[K, V]>, combine: (firstValue: V, secondValue: V, key: K) => V): Collection<K, V>;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type Keep<V> = {
|
||||
keep: false;
|
||||
} | {
|
||||
keep: true;
|
||||
value: V;
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type Comparator<K, V> = (firstValue: V, secondValue: V, firstKey: K, secondKey: K) => number;
|
||||
|
||||
/**
|
||||
* The {@link https://github.com/discordjs/discord.js/blob/main/packages/collection/#readme | @discordjs/collection} version
|
||||
* that you are currently using.
|
||||
*/
|
||||
declare const version: string;
|
||||
|
||||
export { Collection, CollectionConstructor, Comparator, Keep, ReadonlyCollection, version };
|
543
node_modules/@discordjs/collection/dist/index.js
generated
vendored
Normal file
543
node_modules/@discordjs/collection/dist/index.js
generated
vendored
Normal file
|
@ -0,0 +1,543 @@
|
|||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/index.ts
|
||||
var src_exports = {};
|
||||
__export(src_exports, {
|
||||
Collection: () => Collection,
|
||||
version: () => version
|
||||
});
|
||||
module.exports = __toCommonJS(src_exports);
|
||||
|
||||
// src/collection.ts
|
||||
var Collection = class _Collection extends Map {
|
||||
static {
|
||||
__name(this, "Collection");
|
||||
}
|
||||
/**
|
||||
* Obtains the value of the given key if it exists, otherwise sets and returns the value provided by the default value generator.
|
||||
*
|
||||
* @param key - The key to get if it exists, or set otherwise
|
||||
* @param defaultValueGenerator - A function that generates the default value
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.ensure(guildId, () => defaultGuildConfig);
|
||||
* ```
|
||||
*/
|
||||
ensure(key, defaultValueGenerator) {
|
||||
if (this.has(key))
|
||||
return this.get(key);
|
||||
if (typeof defaultValueGenerator !== "function")
|
||||
throw new TypeError(`${defaultValueGenerator} is not a function`);
|
||||
const defaultValue = defaultValueGenerator(key, this);
|
||||
this.set(key, defaultValue);
|
||||
return defaultValue;
|
||||
}
|
||||
/**
|
||||
* Checks if all of the elements exist in the collection.
|
||||
*
|
||||
* @param keys - The keys of the elements to check for
|
||||
* @returns `true` if all of the elements exist, `false` if at least one does not exist.
|
||||
*/
|
||||
hasAll(...keys) {
|
||||
return keys.every((key) => super.has(key));
|
||||
}
|
||||
/**
|
||||
* Checks if any of the elements exist in the collection.
|
||||
*
|
||||
* @param keys - The keys of the elements to check for
|
||||
* @returns `true` if any of the elements exist, `false` if none exist.
|
||||
*/
|
||||
hasAny(...keys) {
|
||||
return keys.some((key) => super.has(key));
|
||||
}
|
||||
first(amount) {
|
||||
if (amount === void 0)
|
||||
return this.values().next().value;
|
||||
if (amount < 0)
|
||||
return this.last(amount * -1);
|
||||
amount = Math.min(this.size, amount);
|
||||
const iter = this.values();
|
||||
return Array.from({ length: amount }, () => iter.next().value);
|
||||
}
|
||||
firstKey(amount) {
|
||||
if (amount === void 0)
|
||||
return this.keys().next().value;
|
||||
if (amount < 0)
|
||||
return this.lastKey(amount * -1);
|
||||
amount = Math.min(this.size, amount);
|
||||
const iter = this.keys();
|
||||
return Array.from({ length: amount }, () => iter.next().value);
|
||||
}
|
||||
last(amount) {
|
||||
const arr = [...this.values()];
|
||||
if (amount === void 0)
|
||||
return arr[arr.length - 1];
|
||||
if (amount < 0)
|
||||
return this.first(amount * -1);
|
||||
if (!amount)
|
||||
return [];
|
||||
return arr.slice(-amount);
|
||||
}
|
||||
lastKey(amount) {
|
||||
const arr = [...this.keys()];
|
||||
if (amount === void 0)
|
||||
return arr[arr.length - 1];
|
||||
if (amount < 0)
|
||||
return this.firstKey(amount * -1);
|
||||
if (!amount)
|
||||
return [];
|
||||
return arr.slice(-amount);
|
||||
}
|
||||
/**
|
||||
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.
|
||||
* Returns the item at a given index, allowing for positive and negative integers.
|
||||
* Negative integers count back from the last item in the collection.
|
||||
*
|
||||
* @param index - The index of the element to obtain
|
||||
*/
|
||||
at(index) {
|
||||
index = Math.floor(index);
|
||||
const arr = [...this.values()];
|
||||
return arr.at(index);
|
||||
}
|
||||
/**
|
||||
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.
|
||||
* Returns the key at a given index, allowing for positive and negative integers.
|
||||
* Negative integers count back from the last item in the collection.
|
||||
*
|
||||
* @param index - The index of the key to obtain
|
||||
*/
|
||||
keyAt(index) {
|
||||
index = Math.floor(index);
|
||||
const arr = [...this.keys()];
|
||||
return arr.at(index);
|
||||
}
|
||||
random(amount) {
|
||||
const arr = [...this.values()];
|
||||
if (amount === void 0)
|
||||
return arr[Math.floor(Math.random() * arr.length)];
|
||||
if (!arr.length || !amount)
|
||||
return [];
|
||||
return Array.from(
|
||||
{ length: Math.min(amount, arr.length) },
|
||||
() => arr.splice(Math.floor(Math.random() * arr.length), 1)[0]
|
||||
);
|
||||
}
|
||||
randomKey(amount) {
|
||||
const arr = [...this.keys()];
|
||||
if (amount === void 0)
|
||||
return arr[Math.floor(Math.random() * arr.length)];
|
||||
if (!arr.length || !amount)
|
||||
return [];
|
||||
return Array.from(
|
||||
{ length: Math.min(amount, arr.length) },
|
||||
() => arr.splice(Math.floor(Math.random() * arr.length), 1)[0]
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse | Array.reverse()}
|
||||
* but returns a Collection instead of an Array.
|
||||
*/
|
||||
reverse() {
|
||||
const entries = [...this.entries()].reverse();
|
||||
this.clear();
|
||||
for (const [key, value] of entries)
|
||||
this.set(key, value);
|
||||
return this;
|
||||
}
|
||||
find(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
for (const [key, val] of this) {
|
||||
if (fn(val, key, this))
|
||||
return val;
|
||||
}
|
||||
return void 0;
|
||||
}
|
||||
findKey(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
for (const [key, val] of this) {
|
||||
if (fn(val, key, this))
|
||||
return key;
|
||||
}
|
||||
return void 0;
|
||||
}
|
||||
sweep(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
const previousSize = this.size;
|
||||
for (const [key, val] of this) {
|
||||
if (fn(val, key, this))
|
||||
this.delete(key);
|
||||
}
|
||||
return previousSize - this.size;
|
||||
}
|
||||
filter(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
const results = new this.constructor[Symbol.species]();
|
||||
for (const [key, val] of this) {
|
||||
if (fn(val, key, this))
|
||||
results.set(key, val);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
partition(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
const results = [
|
||||
new this.constructor[Symbol.species](),
|
||||
new this.constructor[Symbol.species]()
|
||||
];
|
||||
for (const [key, val] of this) {
|
||||
if (fn(val, key, this)) {
|
||||
results[0].set(key, val);
|
||||
} else {
|
||||
results[1].set(key, val);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
flatMap(fn, thisArg) {
|
||||
const collections = this.map(fn, thisArg);
|
||||
return new this.constructor[Symbol.species]().concat(...collections);
|
||||
}
|
||||
map(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
const iter = this.entries();
|
||||
return Array.from({ length: this.size }, () => {
|
||||
const [key, value] = iter.next().value;
|
||||
return fn(value, key, this);
|
||||
});
|
||||
}
|
||||
mapValues(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
const coll = new this.constructor[Symbol.species]();
|
||||
for (const [key, val] of this)
|
||||
coll.set(key, fn(val, key, this));
|
||||
return coll;
|
||||
}
|
||||
some(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
for (const [key, val] of this) {
|
||||
if (fn(val, key, this))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
every(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
for (const [key, val] of this) {
|
||||
if (!fn(val, key, this))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Applies a function to produce a single value. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce | Array.reduce()}.
|
||||
*
|
||||
* @param fn - Function used to reduce, taking four arguments; `accumulator`, `currentValue`, `currentKey`,
|
||||
* and `collection`
|
||||
* @param initialValue - Starting value for the accumulator
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.reduce((acc, guild) => acc + guild.memberCount, 0);
|
||||
* ```
|
||||
*/
|
||||
reduce(fn, initialValue) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
let accumulator;
|
||||
const iterator = this.entries();
|
||||
if (initialValue === void 0) {
|
||||
if (this.size === 0)
|
||||
throw new TypeError("Reduce of empty collection with no initial value");
|
||||
accumulator = iterator.next().value[1];
|
||||
} else {
|
||||
accumulator = initialValue;
|
||||
}
|
||||
for (const [key, value] of iterator) {
|
||||
accumulator = fn(accumulator, value, key, this);
|
||||
}
|
||||
return accumulator;
|
||||
}
|
||||
each(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
for (const [key, value] of this) {
|
||||
fn(value, key, this);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
tap(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
fn(this);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Creates an identical shallow copy of this collection.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const newColl = someColl.clone();
|
||||
* ```
|
||||
*/
|
||||
clone() {
|
||||
return new this.constructor[Symbol.species](this);
|
||||
}
|
||||
/**
|
||||
* Combines this collection with others into a new collection. None of the source collections are modified.
|
||||
*
|
||||
* @param collections - Collections to merge
|
||||
* @example
|
||||
* ```ts
|
||||
* const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);
|
||||
* ```
|
||||
*/
|
||||
concat(...collections) {
|
||||
const newColl = this.clone();
|
||||
for (const coll of collections) {
|
||||
for (const [key, val] of coll)
|
||||
newColl.set(key, val);
|
||||
}
|
||||
return newColl;
|
||||
}
|
||||
/**
|
||||
* Checks if this collection shares identical items with another.
|
||||
* This is different to checking for equality using equal-signs, because
|
||||
* the collections may be different objects, but contain the same data.
|
||||
*
|
||||
* @param collection - Collection to compare with
|
||||
* @returns Whether the collections have identical contents
|
||||
*/
|
||||
equals(collection) {
|
||||
if (!collection)
|
||||
return false;
|
||||
if (this === collection)
|
||||
return true;
|
||||
if (this.size !== collection.size)
|
||||
return false;
|
||||
for (const [key, value] of this) {
|
||||
if (!collection.has(key) || value !== collection.get(key)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* The sort method sorts the items of a collection in place and returns it.
|
||||
* The sort is not necessarily stable in Node 10 or older.
|
||||
* The default sort order is according to string Unicode code points.
|
||||
*
|
||||
* @param compareFunction - Specifies a function that defines the sort order.
|
||||
* If omitted, the collection is sorted according to each character's Unicode code point value, according to the string conversion of each element.
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.sort((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
||||
* ```
|
||||
*/
|
||||
sort(compareFunction = _Collection.defaultSort) {
|
||||
const entries = [...this.entries()];
|
||||
entries.sort((a, b) => compareFunction(a[1], b[1], a[0], b[0]));
|
||||
super.clear();
|
||||
for (const [key, value] of entries) {
|
||||
super.set(key, value);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* The intersect method returns a new structure containing items where the keys and values are present in both original structures.
|
||||
*
|
||||
* @param other - The other Collection to filter against
|
||||
*/
|
||||
intersect(other) {
|
||||
const coll = new this.constructor[Symbol.species]();
|
||||
for (const [key, value] of other) {
|
||||
if (this.has(key) && Object.is(value, this.get(key))) {
|
||||
coll.set(key, value);
|
||||
}
|
||||
}
|
||||
return coll;
|
||||
}
|
||||
/**
|
||||
* The subtract method returns a new structure containing items where the keys and values of the original structure are not present in the other.
|
||||
*
|
||||
* @param other - The other Collection to filter against
|
||||
*/
|
||||
subtract(other) {
|
||||
const coll = new this.constructor[Symbol.species]();
|
||||
for (const [key, value] of this) {
|
||||
if (!other.has(key) || !Object.is(value, other.get(key))) {
|
||||
coll.set(key, value);
|
||||
}
|
||||
}
|
||||
return coll;
|
||||
}
|
||||
/**
|
||||
* The difference method returns a new structure containing items where the key is present in one of the original structures but not the other.
|
||||
*
|
||||
* @param other - The other Collection to filter against
|
||||
*/
|
||||
difference(other) {
|
||||
const coll = new this.constructor[Symbol.species]();
|
||||
for (const [key, value] of other) {
|
||||
if (!this.has(key))
|
||||
coll.set(key, value);
|
||||
}
|
||||
for (const [key, value] of this) {
|
||||
if (!other.has(key))
|
||||
coll.set(key, value);
|
||||
}
|
||||
return coll;
|
||||
}
|
||||
/**
|
||||
* Merges two Collections together into a new Collection.
|
||||
*
|
||||
* @param other - The other Collection to merge with
|
||||
* @param whenInSelf - Function getting the result if the entry only exists in this Collection
|
||||
* @param whenInOther - Function getting the result if the entry only exists in the other Collection
|
||||
* @param whenInBoth - Function getting the result if the entry exists in both Collections
|
||||
* @example
|
||||
* ```ts
|
||||
* // Sums up the entries in two collections.
|
||||
* coll.merge(
|
||||
* other,
|
||||
* x => ({ keep: true, value: x }),
|
||||
* y => ({ keep: true, value: y }),
|
||||
* (x, y) => ({ keep: true, value: x + y }),
|
||||
* );
|
||||
* ```
|
||||
* @example
|
||||
* ```ts
|
||||
* // Intersects two collections in a left-biased manner.
|
||||
* coll.merge(
|
||||
* other,
|
||||
* x => ({ keep: false }),
|
||||
* y => ({ keep: false }),
|
||||
* (x, _) => ({ keep: true, value: x }),
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
merge(other, whenInSelf, whenInOther, whenInBoth) {
|
||||
const coll = new this.constructor[Symbol.species]();
|
||||
const keys = /* @__PURE__ */ new Set([...this.keys(), ...other.keys()]);
|
||||
for (const key of keys) {
|
||||
const hasInSelf = this.has(key);
|
||||
const hasInOther = other.has(key);
|
||||
if (hasInSelf && hasInOther) {
|
||||
const result = whenInBoth(this.get(key), other.get(key), key);
|
||||
if (result.keep)
|
||||
coll.set(key, result.value);
|
||||
} else if (hasInSelf) {
|
||||
const result = whenInSelf(this.get(key), key);
|
||||
if (result.keep)
|
||||
coll.set(key, result.value);
|
||||
} else if (hasInOther) {
|
||||
const result = whenInOther(other.get(key), key);
|
||||
if (result.keep)
|
||||
coll.set(key, result.value);
|
||||
}
|
||||
}
|
||||
return coll;
|
||||
}
|
||||
/**
|
||||
* The sorted method sorts the items of a collection and returns it.
|
||||
* The sort is not necessarily stable in Node 10 or older.
|
||||
* The default sort order is according to string Unicode code points.
|
||||
*
|
||||
* @param compareFunction - Specifies a function that defines the sort order.
|
||||
* If omitted, the collection is sorted according to each character's Unicode code point value,
|
||||
* according to the string conversion of each element.
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.sorted((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
||||
* ```
|
||||
*/
|
||||
sorted(compareFunction = _Collection.defaultSort) {
|
||||
return new this.constructor[Symbol.species](this).sort((av, bv, ak, bk) => compareFunction(av, bv, ak, bk));
|
||||
}
|
||||
toJSON() {
|
||||
return [...this.values()];
|
||||
}
|
||||
static defaultSort(firstValue, secondValue) {
|
||||
return Number(firstValue > secondValue) || Number(firstValue === secondValue) - 1;
|
||||
}
|
||||
/**
|
||||
* Creates a Collection from a list of entries.
|
||||
*
|
||||
* @param entries - The list of entries
|
||||
* @param combine - Function to combine an existing entry with a new one
|
||||
* @example
|
||||
* ```ts
|
||||
* Collection.combineEntries([["a", 1], ["b", 2], ["a", 2]], (x, y) => x + y);
|
||||
* // returns Collection { "a" => 3, "b" => 2 }
|
||||
* ```
|
||||
*/
|
||||
static combineEntries(entries, combine) {
|
||||
const coll = new _Collection();
|
||||
for (const [key, value] of entries) {
|
||||
if (coll.has(key)) {
|
||||
coll.set(key, combine(coll.get(key), value, key));
|
||||
} else {
|
||||
coll.set(key, value);
|
||||
}
|
||||
}
|
||||
return coll;
|
||||
}
|
||||
};
|
||||
|
||||
// src/index.ts
|
||||
var version = "1.5.3";
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
Collection,
|
||||
version
|
||||
});
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@discordjs/collection/dist/index.js.map
generated
vendored
Normal file
1
node_modules/@discordjs/collection/dist/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
517
node_modules/@discordjs/collection/dist/index.mjs
generated
vendored
Normal file
517
node_modules/@discordjs/collection/dist/index.mjs
generated
vendored
Normal file
|
@ -0,0 +1,517 @@
|
|||
var __defProp = Object.defineProperty;
|
||||
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
||||
|
||||
// src/collection.ts
|
||||
var Collection = class _Collection extends Map {
|
||||
static {
|
||||
__name(this, "Collection");
|
||||
}
|
||||
/**
|
||||
* Obtains the value of the given key if it exists, otherwise sets and returns the value provided by the default value generator.
|
||||
*
|
||||
* @param key - The key to get if it exists, or set otherwise
|
||||
* @param defaultValueGenerator - A function that generates the default value
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.ensure(guildId, () => defaultGuildConfig);
|
||||
* ```
|
||||
*/
|
||||
ensure(key, defaultValueGenerator) {
|
||||
if (this.has(key))
|
||||
return this.get(key);
|
||||
if (typeof defaultValueGenerator !== "function")
|
||||
throw new TypeError(`${defaultValueGenerator} is not a function`);
|
||||
const defaultValue = defaultValueGenerator(key, this);
|
||||
this.set(key, defaultValue);
|
||||
return defaultValue;
|
||||
}
|
||||
/**
|
||||
* Checks if all of the elements exist in the collection.
|
||||
*
|
||||
* @param keys - The keys of the elements to check for
|
||||
* @returns `true` if all of the elements exist, `false` if at least one does not exist.
|
||||
*/
|
||||
hasAll(...keys) {
|
||||
return keys.every((key) => super.has(key));
|
||||
}
|
||||
/**
|
||||
* Checks if any of the elements exist in the collection.
|
||||
*
|
||||
* @param keys - The keys of the elements to check for
|
||||
* @returns `true` if any of the elements exist, `false` if none exist.
|
||||
*/
|
||||
hasAny(...keys) {
|
||||
return keys.some((key) => super.has(key));
|
||||
}
|
||||
first(amount) {
|
||||
if (amount === void 0)
|
||||
return this.values().next().value;
|
||||
if (amount < 0)
|
||||
return this.last(amount * -1);
|
||||
amount = Math.min(this.size, amount);
|
||||
const iter = this.values();
|
||||
return Array.from({ length: amount }, () => iter.next().value);
|
||||
}
|
||||
firstKey(amount) {
|
||||
if (amount === void 0)
|
||||
return this.keys().next().value;
|
||||
if (amount < 0)
|
||||
return this.lastKey(amount * -1);
|
||||
amount = Math.min(this.size, amount);
|
||||
const iter = this.keys();
|
||||
return Array.from({ length: amount }, () => iter.next().value);
|
||||
}
|
||||
last(amount) {
|
||||
const arr = [...this.values()];
|
||||
if (amount === void 0)
|
||||
return arr[arr.length - 1];
|
||||
if (amount < 0)
|
||||
return this.first(amount * -1);
|
||||
if (!amount)
|
||||
return [];
|
||||
return arr.slice(-amount);
|
||||
}
|
||||
lastKey(amount) {
|
||||
const arr = [...this.keys()];
|
||||
if (amount === void 0)
|
||||
return arr[arr.length - 1];
|
||||
if (amount < 0)
|
||||
return this.firstKey(amount * -1);
|
||||
if (!amount)
|
||||
return [];
|
||||
return arr.slice(-amount);
|
||||
}
|
||||
/**
|
||||
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.
|
||||
* Returns the item at a given index, allowing for positive and negative integers.
|
||||
* Negative integers count back from the last item in the collection.
|
||||
*
|
||||
* @param index - The index of the element to obtain
|
||||
*/
|
||||
at(index) {
|
||||
index = Math.floor(index);
|
||||
const arr = [...this.values()];
|
||||
return arr.at(index);
|
||||
}
|
||||
/**
|
||||
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.
|
||||
* Returns the key at a given index, allowing for positive and negative integers.
|
||||
* Negative integers count back from the last item in the collection.
|
||||
*
|
||||
* @param index - The index of the key to obtain
|
||||
*/
|
||||
keyAt(index) {
|
||||
index = Math.floor(index);
|
||||
const arr = [...this.keys()];
|
||||
return arr.at(index);
|
||||
}
|
||||
random(amount) {
|
||||
const arr = [...this.values()];
|
||||
if (amount === void 0)
|
||||
return arr[Math.floor(Math.random() * arr.length)];
|
||||
if (!arr.length || !amount)
|
||||
return [];
|
||||
return Array.from(
|
||||
{ length: Math.min(amount, arr.length) },
|
||||
() => arr.splice(Math.floor(Math.random() * arr.length), 1)[0]
|
||||
);
|
||||
}
|
||||
randomKey(amount) {
|
||||
const arr = [...this.keys()];
|
||||
if (amount === void 0)
|
||||
return arr[Math.floor(Math.random() * arr.length)];
|
||||
if (!arr.length || !amount)
|
||||
return [];
|
||||
return Array.from(
|
||||
{ length: Math.min(amount, arr.length) },
|
||||
() => arr.splice(Math.floor(Math.random() * arr.length), 1)[0]
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse | Array.reverse()}
|
||||
* but returns a Collection instead of an Array.
|
||||
*/
|
||||
reverse() {
|
||||
const entries = [...this.entries()].reverse();
|
||||
this.clear();
|
||||
for (const [key, value] of entries)
|
||||
this.set(key, value);
|
||||
return this;
|
||||
}
|
||||
find(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
for (const [key, val] of this) {
|
||||
if (fn(val, key, this))
|
||||
return val;
|
||||
}
|
||||
return void 0;
|
||||
}
|
||||
findKey(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
for (const [key, val] of this) {
|
||||
if (fn(val, key, this))
|
||||
return key;
|
||||
}
|
||||
return void 0;
|
||||
}
|
||||
sweep(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
const previousSize = this.size;
|
||||
for (const [key, val] of this) {
|
||||
if (fn(val, key, this))
|
||||
this.delete(key);
|
||||
}
|
||||
return previousSize - this.size;
|
||||
}
|
||||
filter(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
const results = new this.constructor[Symbol.species]();
|
||||
for (const [key, val] of this) {
|
||||
if (fn(val, key, this))
|
||||
results.set(key, val);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
partition(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
const results = [
|
||||
new this.constructor[Symbol.species](),
|
||||
new this.constructor[Symbol.species]()
|
||||
];
|
||||
for (const [key, val] of this) {
|
||||
if (fn(val, key, this)) {
|
||||
results[0].set(key, val);
|
||||
} else {
|
||||
results[1].set(key, val);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
flatMap(fn, thisArg) {
|
||||
const collections = this.map(fn, thisArg);
|
||||
return new this.constructor[Symbol.species]().concat(...collections);
|
||||
}
|
||||
map(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
const iter = this.entries();
|
||||
return Array.from({ length: this.size }, () => {
|
||||
const [key, value] = iter.next().value;
|
||||
return fn(value, key, this);
|
||||
});
|
||||
}
|
||||
mapValues(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
const coll = new this.constructor[Symbol.species]();
|
||||
for (const [key, val] of this)
|
||||
coll.set(key, fn(val, key, this));
|
||||
return coll;
|
||||
}
|
||||
some(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
for (const [key, val] of this) {
|
||||
if (fn(val, key, this))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
every(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
for (const [key, val] of this) {
|
||||
if (!fn(val, key, this))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Applies a function to produce a single value. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce | Array.reduce()}.
|
||||
*
|
||||
* @param fn - Function used to reduce, taking four arguments; `accumulator`, `currentValue`, `currentKey`,
|
||||
* and `collection`
|
||||
* @param initialValue - Starting value for the accumulator
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.reduce((acc, guild) => acc + guild.memberCount, 0);
|
||||
* ```
|
||||
*/
|
||||
reduce(fn, initialValue) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
let accumulator;
|
||||
const iterator = this.entries();
|
||||
if (initialValue === void 0) {
|
||||
if (this.size === 0)
|
||||
throw new TypeError("Reduce of empty collection with no initial value");
|
||||
accumulator = iterator.next().value[1];
|
||||
} else {
|
||||
accumulator = initialValue;
|
||||
}
|
||||
for (const [key, value] of iterator) {
|
||||
accumulator = fn(accumulator, value, key, this);
|
||||
}
|
||||
return accumulator;
|
||||
}
|
||||
each(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
for (const [key, value] of this) {
|
||||
fn(value, key, this);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
tap(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
fn(this);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Creates an identical shallow copy of this collection.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const newColl = someColl.clone();
|
||||
* ```
|
||||
*/
|
||||
clone() {
|
||||
return new this.constructor[Symbol.species](this);
|
||||
}
|
||||
/**
|
||||
* Combines this collection with others into a new collection. None of the source collections are modified.
|
||||
*
|
||||
* @param collections - Collections to merge
|
||||
* @example
|
||||
* ```ts
|
||||
* const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);
|
||||
* ```
|
||||
*/
|
||||
concat(...collections) {
|
||||
const newColl = this.clone();
|
||||
for (const coll of collections) {
|
||||
for (const [key, val] of coll)
|
||||
newColl.set(key, val);
|
||||
}
|
||||
return newColl;
|
||||
}
|
||||
/**
|
||||
* Checks if this collection shares identical items with another.
|
||||
* This is different to checking for equality using equal-signs, because
|
||||
* the collections may be different objects, but contain the same data.
|
||||
*
|
||||
* @param collection - Collection to compare with
|
||||
* @returns Whether the collections have identical contents
|
||||
*/
|
||||
equals(collection) {
|
||||
if (!collection)
|
||||
return false;
|
||||
if (this === collection)
|
||||
return true;
|
||||
if (this.size !== collection.size)
|
||||
return false;
|
||||
for (const [key, value] of this) {
|
||||
if (!collection.has(key) || value !== collection.get(key)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* The sort method sorts the items of a collection in place and returns it.
|
||||
* The sort is not necessarily stable in Node 10 or older.
|
||||
* The default sort order is according to string Unicode code points.
|
||||
*
|
||||
* @param compareFunction - Specifies a function that defines the sort order.
|
||||
* If omitted, the collection is sorted according to each character's Unicode code point value, according to the string conversion of each element.
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.sort((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
||||
* ```
|
||||
*/
|
||||
sort(compareFunction = _Collection.defaultSort) {
|
||||
const entries = [...this.entries()];
|
||||
entries.sort((a, b) => compareFunction(a[1], b[1], a[0], b[0]));
|
||||
super.clear();
|
||||
for (const [key, value] of entries) {
|
||||
super.set(key, value);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* The intersect method returns a new structure containing items where the keys and values are present in both original structures.
|
||||
*
|
||||
* @param other - The other Collection to filter against
|
||||
*/
|
||||
intersect(other) {
|
||||
const coll = new this.constructor[Symbol.species]();
|
||||
for (const [key, value] of other) {
|
||||
if (this.has(key) && Object.is(value, this.get(key))) {
|
||||
coll.set(key, value);
|
||||
}
|
||||
}
|
||||
return coll;
|
||||
}
|
||||
/**
|
||||
* The subtract method returns a new structure containing items where the keys and values of the original structure are not present in the other.
|
||||
*
|
||||
* @param other - The other Collection to filter against
|
||||
*/
|
||||
subtract(other) {
|
||||
const coll = new this.constructor[Symbol.species]();
|
||||
for (const [key, value] of this) {
|
||||
if (!other.has(key) || !Object.is(value, other.get(key))) {
|
||||
coll.set(key, value);
|
||||
}
|
||||
}
|
||||
return coll;
|
||||
}
|
||||
/**
|
||||
* The difference method returns a new structure containing items where the key is present in one of the original structures but not the other.
|
||||
*
|
||||
* @param other - The other Collection to filter against
|
||||
*/
|
||||
difference(other) {
|
||||
const coll = new this.constructor[Symbol.species]();
|
||||
for (const [key, value] of other) {
|
||||
if (!this.has(key))
|
||||
coll.set(key, value);
|
||||
}
|
||||
for (const [key, value] of this) {
|
||||
if (!other.has(key))
|
||||
coll.set(key, value);
|
||||
}
|
||||
return coll;
|
||||
}
|
||||
/**
|
||||
* Merges two Collections together into a new Collection.
|
||||
*
|
||||
* @param other - The other Collection to merge with
|
||||
* @param whenInSelf - Function getting the result if the entry only exists in this Collection
|
||||
* @param whenInOther - Function getting the result if the entry only exists in the other Collection
|
||||
* @param whenInBoth - Function getting the result if the entry exists in both Collections
|
||||
* @example
|
||||
* ```ts
|
||||
* // Sums up the entries in two collections.
|
||||
* coll.merge(
|
||||
* other,
|
||||
* x => ({ keep: true, value: x }),
|
||||
* y => ({ keep: true, value: y }),
|
||||
* (x, y) => ({ keep: true, value: x + y }),
|
||||
* );
|
||||
* ```
|
||||
* @example
|
||||
* ```ts
|
||||
* // Intersects two collections in a left-biased manner.
|
||||
* coll.merge(
|
||||
* other,
|
||||
* x => ({ keep: false }),
|
||||
* y => ({ keep: false }),
|
||||
* (x, _) => ({ keep: true, value: x }),
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
merge(other, whenInSelf, whenInOther, whenInBoth) {
|
||||
const coll = new this.constructor[Symbol.species]();
|
||||
const keys = /* @__PURE__ */ new Set([...this.keys(), ...other.keys()]);
|
||||
for (const key of keys) {
|
||||
const hasInSelf = this.has(key);
|
||||
const hasInOther = other.has(key);
|
||||
if (hasInSelf && hasInOther) {
|
||||
const result = whenInBoth(this.get(key), other.get(key), key);
|
||||
if (result.keep)
|
||||
coll.set(key, result.value);
|
||||
} else if (hasInSelf) {
|
||||
const result = whenInSelf(this.get(key), key);
|
||||
if (result.keep)
|
||||
coll.set(key, result.value);
|
||||
} else if (hasInOther) {
|
||||
const result = whenInOther(other.get(key), key);
|
||||
if (result.keep)
|
||||
coll.set(key, result.value);
|
||||
}
|
||||
}
|
||||
return coll;
|
||||
}
|
||||
/**
|
||||
* The sorted method sorts the items of a collection and returns it.
|
||||
* The sort is not necessarily stable in Node 10 or older.
|
||||
* The default sort order is according to string Unicode code points.
|
||||
*
|
||||
* @param compareFunction - Specifies a function that defines the sort order.
|
||||
* If omitted, the collection is sorted according to each character's Unicode code point value,
|
||||
* according to the string conversion of each element.
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.sorted((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
||||
* ```
|
||||
*/
|
||||
sorted(compareFunction = _Collection.defaultSort) {
|
||||
return new this.constructor[Symbol.species](this).sort((av, bv, ak, bk) => compareFunction(av, bv, ak, bk));
|
||||
}
|
||||
toJSON() {
|
||||
return [...this.values()];
|
||||
}
|
||||
static defaultSort(firstValue, secondValue) {
|
||||
return Number(firstValue > secondValue) || Number(firstValue === secondValue) - 1;
|
||||
}
|
||||
/**
|
||||
* Creates a Collection from a list of entries.
|
||||
*
|
||||
* @param entries - The list of entries
|
||||
* @param combine - Function to combine an existing entry with a new one
|
||||
* @example
|
||||
* ```ts
|
||||
* Collection.combineEntries([["a", 1], ["b", 2], ["a", 2]], (x, y) => x + y);
|
||||
* // returns Collection { "a" => 3, "b" => 2 }
|
||||
* ```
|
||||
*/
|
||||
static combineEntries(entries, combine) {
|
||||
const coll = new _Collection();
|
||||
for (const [key, value] of entries) {
|
||||
if (coll.has(key)) {
|
||||
coll.set(key, combine(coll.get(key), value, key));
|
||||
} else {
|
||||
coll.set(key, value);
|
||||
}
|
||||
}
|
||||
return coll;
|
||||
}
|
||||
};
|
||||
|
||||
// src/index.ts
|
||||
var version = "1.5.3";
|
||||
export {
|
||||
Collection,
|
||||
version
|
||||
};
|
||||
//# sourceMappingURL=index.mjs.map
|
1
node_modules/@discordjs/collection/dist/index.mjs.map
generated
vendored
Normal file
1
node_modules/@discordjs/collection/dist/index.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
76
node_modules/@discordjs/collection/package.json
generated
vendored
Normal file
76
node_modules/@discordjs/collection/package.json
generated
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
{
|
||||
"name": "@discordjs/collection",
|
||||
"version": "1.5.3",
|
||||
"description": "Utility data structure used in discord.js",
|
||||
"scripts": {
|
||||
"test": "vitest run",
|
||||
"build": "tsup",
|
||||
"build:docs": "tsc -p tsconfig.docs.json",
|
||||
"lint": "prettier --check . && cross-env TIMING=1 eslint src __tests__ --ext .mjs,.js,.ts --format=pretty",
|
||||
"format": "prettier --write . && cross-env TIMING=1 eslint src __tests__ --ext .mjs,.js,.ts --fix --format=pretty",
|
||||
"fmt": "yarn format",
|
||||
"docs": "yarn build:docs && api-extractor run --local && api-extractor run --local --config ./api-extractor-docs.json",
|
||||
"prepack": "yarn lint && yarn test && yarn build",
|
||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/collection/*'",
|
||||
"release": "cliff-jumper"
|
||||
},
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.mjs",
|
||||
"require": "./dist/index.js"
|
||||
},
|
||||
"directories": {
|
||||
"lib": "src",
|
||||
"test": "__tests__"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"contributors": [
|
||||
"Crawl <icrawltogo@gmail.com>",
|
||||
"Amish Shah <amishshah.2k@gmail.com>",
|
||||
"SpaceEEC <spaceeec@yahoo.com>",
|
||||
"Vlad Frangu <kingdgrizzle@gmail.com>",
|
||||
"Aura Román <kyradiscord@gmail.com>"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"keywords": [
|
||||
"map",
|
||||
"collection",
|
||||
"utility"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/discordjs/discord.js.git",
|
||||
"directory": "packages/collection"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/discordjs/discord.js/issues"
|
||||
},
|
||||
"homepage": "https://discord.js.org",
|
||||
"devDependencies": {
|
||||
"@favware/cliff-jumper": "^2.1.1",
|
||||
"@microsoft/api-extractor": "^7.36.4",
|
||||
"@types/node": "16.18.40",
|
||||
"@vitest/coverage-v8": "^0.34.2",
|
||||
"cross-env": "^7.0.3",
|
||||
"esbuild-plugin-version-injector": "^1.2.0",
|
||||
"eslint": "^8.47.0",
|
||||
"eslint-config-neon": "^0.1.47",
|
||||
"eslint-formatter-pretty": "^5.0.0",
|
||||
"prettier": "^2.8.8",
|
||||
"tsup": "^7.2.0",
|
||||
"turbo": "^1.10.12",
|
||||
"typescript": "^5.1.6",
|
||||
"vitest": "^0.34.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.11.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
191
node_modules/@discordjs/formatters/LICENSE
generated
vendored
Normal file
191
node_modules/@discordjs/formatters/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,191 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Copyright 2021 Noel Buechler
|
||||
Copyright 2021 Vlad Frangu
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
82
node_modules/@discordjs/formatters/README.md
generated
vendored
Normal file
82
node_modules/@discordjs/formatters/README.md
generated
vendored
Normal file
|
@ -0,0 +1,82 @@
|
|||
<div align="center">
|
||||
<br />
|
||||
<p>
|
||||
<a href="https://discord.js.org"><img src="https://discord.js.org/static/logo.svg" width="546" alt="discord.js" /></a>
|
||||
</p>
|
||||
<br />
|
||||
<p>
|
||||
<a href="https://discord.gg/djs"><img src="https://img.shields.io/discord/222078108977594368?color=5865F2&logo=discord&logoColor=white" alt="Discord server" /></a>
|
||||
<a href="https://www.npmjs.com/package/@discordjs/formatters"><img src="https://img.shields.io/npm/v/@discordjs/formatters.svg?maxAge=3600" alt="npm version" /></a>
|
||||
<a href="https://www.npmjs.com/package/@discordjs/formatters"><img src="https://img.shields.io/npm/dt/@discordjs/formatters.svg?maxAge=3600" alt="npm downloads" /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Build status" /></a>
|
||||
<a href="https://codecov.io/gh/discordjs/discord.js" ><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2&flag=formatters" alt="Code coverage" /></a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
|
||||
<a href="https://www.cloudflare.com"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-workers.png" alt="Cloudflare Workers" height="44" /></a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
## About
|
||||
|
||||
`@discordjs/formatters` is a collection of functions for formatting strings to be used on Discord.
|
||||
|
||||
## Installation
|
||||
|
||||
**Node.js 16.11.0 or newer is required.**
|
||||
|
||||
```sh
|
||||
npm install @discordjs/formatters
|
||||
yarn add @discordjs/formatters
|
||||
pnpm add @discordjs/formatters
|
||||
bun add @discordjs/formatters
|
||||
```
|
||||
|
||||
## Example usage
|
||||
|
||||
````ts
|
||||
import { codeBlock } from '@discordjs/formatters';
|
||||
|
||||
const formattedCode = codeBlock('hello world!');
|
||||
console.log(formattedCode);
|
||||
|
||||
// Prints:
|
||||
// ```
|
||||
// hello world!
|
||||
// ```
|
||||
````
|
||||
|
||||
## Links
|
||||
|
||||
- [Website][website] ([source][website-source])
|
||||
- [Documentation][documentation]
|
||||
- [Guide][guide] ([source][guide-source])
|
||||
Also see the v13 to v14 [Update Guide][guide-update], which includes updated and removed items from the library.
|
||||
- [discord.js Discord server][discord]
|
||||
- [Discord API Discord server][discord-api]
|
||||
- [GitHub][source]
|
||||
- [npm][npm]
|
||||
- [Related libraries][related-libs]
|
||||
|
||||
## Contributing
|
||||
|
||||
Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the
|
||||
[documentation][documentation].
|
||||
See [the contribution guide][contributing] if you'd like to submit a PR.
|
||||
|
||||
## Help
|
||||
|
||||
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to join our official [discord.js Server][discord].
|
||||
|
||||
[website]: https://discord.js.org
|
||||
[website-source]: https://github.com/discordjs/discord.js/tree/main/apps/website
|
||||
[documentation]: https://discord.js.org/docs/packages/formatters/stable
|
||||
[guide]: https://discordjs.guide/
|
||||
[guide-source]: https://github.com/discordjs/guide
|
||||
[guide-update]: https://discordjs.guide/additional-info/changes-in-v14.html
|
||||
[discord]: https://discord.gg/djs
|
||||
[discord-api]: https://discord.gg/discord-api
|
||||
[source]: https://github.com/discordjs/discord.js/tree/main/packages/formatters
|
||||
[npm]: https://www.npmjs.com/package/@discordjs/formatters
|
||||
[related-libs]: https://discord.com/developers/docs/topics/community-resources#libraries
|
||||
[contributing]: https://github.com/discordjs/discord.js/blob/main/.github/CONTRIBUTING.md
|
586
node_modules/@discordjs/formatters/dist/index.d.mts
generated
vendored
Normal file
586
node_modules/@discordjs/formatters/dist/index.d.mts
generated
vendored
Normal file
|
@ -0,0 +1,586 @@
|
|||
import { URL } from 'node:url';
|
||||
import { Snowflake } from 'discord-api-types/globals';
|
||||
|
||||
/**
|
||||
* The options that affect what will be escaped.
|
||||
*/
|
||||
interface EscapeMarkdownOptions {
|
||||
/**
|
||||
* Whether to escape bold text.
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
bold?: boolean;
|
||||
/**
|
||||
* Whether to escape bulleted lists.
|
||||
*
|
||||
* @defaultValue `false`
|
||||
*/
|
||||
bulletedList?: boolean;
|
||||
/**
|
||||
* Whether to escape code blocks.
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
codeBlock?: boolean;
|
||||
/**
|
||||
* Whether to escape text inside code blocks.
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
codeBlockContent?: boolean;
|
||||
/**
|
||||
* Whether to escape `\`.
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
escape?: boolean;
|
||||
/**
|
||||
* Whether to escape headings.
|
||||
*
|
||||
* @defaultValue `false`
|
||||
*/
|
||||
heading?: boolean;
|
||||
/**
|
||||
* Whether to escape inline code.
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
inlineCode?: boolean;
|
||||
/**
|
||||
* Whether to escape text inside inline code.
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
inlineCodeContent?: boolean;
|
||||
/**
|
||||
* Whether to escape italics.
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
italic?: boolean;
|
||||
/**
|
||||
* Whether to escape masked links.
|
||||
*
|
||||
* @defaultValue `false`
|
||||
*/
|
||||
maskedLink?: boolean;
|
||||
/**
|
||||
* Whether to escape numbered lists.
|
||||
*
|
||||
* @defaultValue `false`
|
||||
*/
|
||||
numberedList?: boolean;
|
||||
/**
|
||||
* Whether to escape spoilers.
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
spoiler?: boolean;
|
||||
/**
|
||||
* Whether to escape strikethroughs.
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
strikethrough?: boolean;
|
||||
/**
|
||||
* Whether to escape underlines.
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
underline?: boolean;
|
||||
}
|
||||
/**
|
||||
* Escapes any Discord-flavored markdown in a string.
|
||||
*
|
||||
* @param text - Content to escape
|
||||
* @param options - Options for escaping the markdown
|
||||
*/
|
||||
declare function escapeMarkdown(text: string, options?: EscapeMarkdownOptions): string;
|
||||
/**
|
||||
* Escapes code block markdown in a string.
|
||||
*
|
||||
* @param text - Content to escape
|
||||
*/
|
||||
declare function escapeCodeBlock(text: string): string;
|
||||
/**
|
||||
* Escapes inline code markdown in a string.
|
||||
*
|
||||
* @param text - Content to escape
|
||||
*/
|
||||
declare function escapeInlineCode(text: string): string;
|
||||
/**
|
||||
* Escapes italic markdown in a string.
|
||||
*
|
||||
* @param text - Content to escape
|
||||
*/
|
||||
declare function escapeItalic(text: string): string;
|
||||
/**
|
||||
* Escapes bold markdown in a string.
|
||||
*
|
||||
* @param text - Content to escape
|
||||
*/
|
||||
declare function escapeBold(text: string): string;
|
||||
/**
|
||||
* Escapes underline markdown in a string.
|
||||
*
|
||||
* @param text - Content to escape
|
||||
*/
|
||||
declare function escapeUnderline(text: string): string;
|
||||
/**
|
||||
* Escapes strikethrough markdown in a string.
|
||||
*
|
||||
* @param text - Content to escape
|
||||
*/
|
||||
declare function escapeStrikethrough(text: string): string;
|
||||
/**
|
||||
* Escapes spoiler markdown in a string.
|
||||
*
|
||||
* @param text - Content to escape
|
||||
*/
|
||||
declare function escapeSpoiler(text: string): string;
|
||||
/**
|
||||
* Escapes escape characters in a string.
|
||||
*
|
||||
* @param text - Content to escape
|
||||
*/
|
||||
declare function escapeEscape(text: string): string;
|
||||
/**
|
||||
* Escapes heading characters in a string.
|
||||
*
|
||||
* @param text - Content to escape
|
||||
*/
|
||||
declare function escapeHeading(text: string): string;
|
||||
/**
|
||||
* Escapes bulleted list characters in a string.
|
||||
*
|
||||
* @param text - Content to escape
|
||||
*/
|
||||
declare function escapeBulletedList(text: string): string;
|
||||
/**
|
||||
* Escapes numbered list characters in a string.
|
||||
*
|
||||
* @param text - Content to escape
|
||||
*/
|
||||
declare function escapeNumberedList(text: string): string;
|
||||
/**
|
||||
* Escapes masked link characters in a string.
|
||||
*
|
||||
* @param text - Content to escape
|
||||
*/
|
||||
declare function escapeMaskedLink(text: string): string;
|
||||
|
||||
/**
|
||||
* Wraps the content inside a code block with no language.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param content - The content to wrap
|
||||
*/
|
||||
declare function codeBlock<Content extends string>(content: Content): `\`\`\`\n${Content}\n\`\`\``;
|
||||
/**
|
||||
* Wraps the content inside a code block with the specified language.
|
||||
*
|
||||
* @typeParam Language - This is inferred by the supplied language
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param language - The language for the code block
|
||||
* @param content - The content to wrap
|
||||
*/
|
||||
declare function codeBlock<Language extends string, Content extends string>(language: Language, content: Content): `\`\`\`${Language}\n${Content}\n\`\`\``;
|
||||
/**
|
||||
* Wraps the content inside \`backticks\` which formats it as inline code.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param content - The content to wrap
|
||||
*/
|
||||
declare function inlineCode<Content extends string>(content: Content): `\`${Content}\``;
|
||||
/**
|
||||
* Formats the content into italic text.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param content - The content to wrap
|
||||
*/
|
||||
declare function italic<Content extends string>(content: Content): `_${Content}_`;
|
||||
/**
|
||||
* Formats the content into bold text.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param content - The content to wrap
|
||||
*/
|
||||
declare function bold<Content extends string>(content: Content): `**${Content}**`;
|
||||
/**
|
||||
* Formats the content into underscored text.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param content - The content to wrap
|
||||
*/
|
||||
declare function underscore<Content extends string>(content: Content): `__${Content}__`;
|
||||
/**
|
||||
* Formats the content into strike-through text.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param content - The content to wrap
|
||||
*/
|
||||
declare function strikethrough<Content extends string>(content: Content): `~~${Content}~~`;
|
||||
/**
|
||||
* Formats the content into a quote.
|
||||
*
|
||||
* @remarks This needs to be at the start of the line for Discord to format it.
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param content - The content to wrap
|
||||
*/
|
||||
declare function quote<Content extends string>(content: Content): `> ${Content}`;
|
||||
/**
|
||||
* Formats the content into a block quote.
|
||||
*
|
||||
* @remarks This needs to be at the start of the line for Discord to format it.
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param content - The content to wrap
|
||||
*/
|
||||
declare function blockQuote<Content extends string>(content: Content): `>>> ${Content}`;
|
||||
/**
|
||||
* Wraps the URL into `<>` which stops it from embedding.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param url - The URL to wrap
|
||||
*/
|
||||
declare function hideLinkEmbed<Content extends string>(url: Content): `<${Content}>`;
|
||||
/**
|
||||
* Wraps the URL into `<>` which stops it from embedding.
|
||||
*
|
||||
* @param url - The URL to wrap
|
||||
*/
|
||||
declare function hideLinkEmbed(url: URL): `<${string}>`;
|
||||
/**
|
||||
* Formats the content and the URL into a masked URL.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param content - The content to display
|
||||
* @param url - The URL the content links to
|
||||
*/
|
||||
declare function hyperlink<Content extends string>(content: Content, url: URL): `[${Content}](${string})`;
|
||||
/**
|
||||
* Formats the content and the URL into a masked URL.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @typeParam Url - This is inferred by the supplied URL
|
||||
* @param content - The content to display
|
||||
* @param url - The URL the content links to
|
||||
*/
|
||||
declare function hyperlink<Content extends string, Url extends string>(content: Content, url: Url): `[${Content}](${Url})`;
|
||||
/**
|
||||
* Formats the content and the URL into a masked URL with a custom tooltip.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @typeParam Title - This is inferred by the supplied title
|
||||
* @param content - The content to display
|
||||
* @param url - The URL the content links to
|
||||
* @param title - The title shown when hovering on the masked link
|
||||
*/
|
||||
declare function hyperlink<Content extends string, Title extends string>(content: Content, url: URL, title: Title): `[${Content}](${string} "${Title}")`;
|
||||
/**
|
||||
* Formats the content and the URL into a masked URL with a custom tooltip.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @typeParam Url - This is inferred by the supplied URL
|
||||
* @typeParam Title - This is inferred by the supplied title
|
||||
* @param content - The content to display
|
||||
* @param url - The URL the content links to
|
||||
* @param title - The title shown when hovering on the masked link
|
||||
*/
|
||||
declare function hyperlink<Content extends string, Url extends string, Title extends string>(content: Content, url: Url, title: Title): `[${Content}](${Url} "${Title}")`;
|
||||
/**
|
||||
* Formats the content into a spoiler.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param content - The content to wrap
|
||||
*/
|
||||
declare function spoiler<Content extends string>(content: Content): `||${Content}||`;
|
||||
/**
|
||||
* Formats a user id into a user mention.
|
||||
*
|
||||
* @typeParam UserId - This is inferred by the supplied user id
|
||||
* @param userId - The user id to format
|
||||
*/
|
||||
declare function userMention<UserId extends Snowflake>(userId: UserId): `<@${UserId}>`;
|
||||
/**
|
||||
* Formats a channel id into a channel mention.
|
||||
*
|
||||
* @typeParam ChannelId - This is inferred by the supplied channel id
|
||||
* @param channelId - The channel id to format
|
||||
*/
|
||||
declare function channelMention<ChannelId extends Snowflake>(channelId: ChannelId): `<#${ChannelId}>`;
|
||||
/**
|
||||
* Formats a role id into a role mention.
|
||||
*
|
||||
* @typeParam RoleId - This is inferred by the supplied role id
|
||||
* @param roleId - The role id to format
|
||||
*/
|
||||
declare function roleMention<RoleId extends Snowflake>(roleId: RoleId): `<@&${RoleId}>`;
|
||||
/**
|
||||
* Formats an application command name, subcommand group name, subcommand name, and id into an application command mention.
|
||||
*
|
||||
* @typeParam CommandName - This is inferred by the supplied command name
|
||||
* @typeParam SubcommandGroupName - This is inferred by the supplied subcommand group name
|
||||
* @typeParam SubcommandName - This is inferred by the supplied subcommand name
|
||||
* @typeParam CommandId - This is inferred by the supplied command id
|
||||
* @param commandName - The application command name to format
|
||||
* @param subcommandGroupName - The subcommand group name to format
|
||||
* @param subcommandName - The subcommand name to format
|
||||
* @param commandId - The application command id to format
|
||||
*/
|
||||
declare function chatInputApplicationCommandMention<CommandName extends string, SubcommandGroupName extends string, SubcommandName extends string, CommandId extends Snowflake>(commandName: CommandName, subcommandGroupName: SubcommandGroupName, subcommandName: SubcommandName, commandId: CommandId): `</${CommandName} ${SubcommandGroupName} ${SubcommandName}:${CommandId}>`;
|
||||
/**
|
||||
* Formats an application command name, subcommand name, and id into an application command mention.
|
||||
*
|
||||
* @typeParam CommandName - This is inferred by the supplied command name
|
||||
* @typeParam SubcommandName - This is inferred by the supplied subcommand name
|
||||
* @typeParam CommandId - This is inferred by the supplied command id
|
||||
* @param commandName - The application command name to format
|
||||
* @param subcommandName - The subcommand name to format
|
||||
* @param commandId - The application command id to format
|
||||
*/
|
||||
declare function chatInputApplicationCommandMention<CommandName extends string, SubcommandName extends string, CommandId extends Snowflake>(commandName: CommandName, subcommandName: SubcommandName, commandId: CommandId): `</${CommandName} ${SubcommandName}:${CommandId}>`;
|
||||
/**
|
||||
* Formats an application command name and id into an application command mention.
|
||||
*
|
||||
* @typeParam CommandName - This is inferred by the supplied command name
|
||||
* @typeParam CommandId - This is inferred by the supplied command id
|
||||
* @param commandName - The application command name to format
|
||||
* @param commandId - The application command id to format
|
||||
*/
|
||||
declare function chatInputApplicationCommandMention<CommandName extends string, CommandId extends Snowflake>(commandName: CommandName, commandId: CommandId): `</${CommandName}:${CommandId}>`;
|
||||
/**
|
||||
* Formats a non-animated emoji id into a fully qualified emoji identifier.
|
||||
*
|
||||
* @typeParam EmojiId - This is inferred by the supplied emoji id
|
||||
* @param emojiId - The emoji id to format
|
||||
*/
|
||||
declare function formatEmoji<EmojiId extends Snowflake>(emojiId: EmojiId, animated?: false): `<:_:${EmojiId}>`;
|
||||
/**
|
||||
* Formats an animated emoji id into a fully qualified emoji identifier.
|
||||
*
|
||||
* @typeParam EmojiId - This is inferred by the supplied emoji id
|
||||
* @param emojiId - The emoji id to format
|
||||
* @param animated - Whether the emoji is animated
|
||||
*/
|
||||
declare function formatEmoji<EmojiId extends Snowflake>(emojiId: EmojiId, animated?: true): `<a:_:${EmojiId}>`;
|
||||
/**
|
||||
* Formats an emoji id into a fully qualified emoji identifier.
|
||||
*
|
||||
* @typeParam EmojiId - This is inferred by the supplied emoji id
|
||||
* @param emojiId - The emoji id to format
|
||||
* @param animated - Whether the emoji is animated
|
||||
*/
|
||||
declare function formatEmoji<EmojiId extends Snowflake>(emojiId: EmojiId, animated?: boolean): `<:_:${EmojiId}>` | `<a:_:${EmojiId}>`;
|
||||
/**
|
||||
* Formats a channel link for a direct message channel.
|
||||
*
|
||||
* @typeParam ChannelId - This is inferred by the supplied channel id
|
||||
* @param channelId - The channel's id
|
||||
*/
|
||||
declare function channelLink<ChannelId extends Snowflake>(channelId: ChannelId): `https://discord.com/channels/@me/${ChannelId}`;
|
||||
/**
|
||||
* Formats a channel link for a guild channel.
|
||||
*
|
||||
* @typeParam ChannelId - This is inferred by the supplied channel id
|
||||
* @typeParam GuildId - This is inferred by the supplied guild id
|
||||
* @param channelId - The channel's id
|
||||
* @param guildId - The guild's id
|
||||
*/
|
||||
declare function channelLink<ChannelId extends Snowflake, GuildId extends Snowflake>(channelId: ChannelId, guildId: GuildId): `https://discord.com/channels/${GuildId}/${ChannelId}`;
|
||||
/**
|
||||
* Formats a message link for a direct message channel.
|
||||
*
|
||||
* @typeParam ChannelId - This is inferred by the supplied channel id
|
||||
* @typeParam MessageId - This is inferred by the supplied message id
|
||||
* @param channelId - The channel's id
|
||||
* @param messageId - The message's id
|
||||
*/
|
||||
declare function messageLink<ChannelId extends Snowflake, MessageId extends Snowflake>(channelId: ChannelId, messageId: MessageId): `https://discord.com/channels/@me/${ChannelId}/${MessageId}`;
|
||||
/**
|
||||
* Formats a message link for a guild channel.
|
||||
*
|
||||
* @typeParam ChannelId - This is inferred by the supplied channel id
|
||||
* @typeParam MessageId - This is inferred by the supplied message id
|
||||
* @typeParam GuildId - This is inferred by the supplied guild id
|
||||
* @param channelId - The channel's id
|
||||
* @param messageId - The message's id
|
||||
* @param guildId - The guild's id
|
||||
*/
|
||||
declare function messageLink<ChannelId extends Snowflake, MessageId extends Snowflake, GuildId extends Snowflake>(channelId: ChannelId, messageId: MessageId, guildId: GuildId): `https://discord.com/channels/${GuildId}/${ChannelId}/${MessageId}`;
|
||||
/**
|
||||
* The heading levels for expanded markdown.
|
||||
*/
|
||||
declare enum HeadingLevel {
|
||||
/**
|
||||
* The first heading level.
|
||||
*/
|
||||
One = 1,
|
||||
/**
|
||||
* The second heading level.
|
||||
*/
|
||||
Two = 2,
|
||||
/**
|
||||
* The third heading level.
|
||||
*/
|
||||
Three = 3
|
||||
}
|
||||
/**
|
||||
* Formats the content into a heading level.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param content - The content to wrap
|
||||
* @param level - The heading level
|
||||
*/
|
||||
declare function heading<Content extends string>(content: Content, level?: HeadingLevel.One): `# ${Content}`;
|
||||
/**
|
||||
* Formats the content into a heading level.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param content - The content to wrap
|
||||
* @param level - The heading level
|
||||
*/
|
||||
declare function heading<Content extends string>(content: Content, level: HeadingLevel.Two): `## ${Content}`;
|
||||
/**
|
||||
* Formats the content into a heading level.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param content - The content to wrap
|
||||
* @param level - The heading level
|
||||
*/
|
||||
declare function heading<Content extends string>(content: Content, level: HeadingLevel.Three): `### ${Content}`;
|
||||
/**
|
||||
* A type that recursively traverses into arrays.
|
||||
*/
|
||||
type RecursiveArray<ItemType> = readonly (ItemType | RecursiveArray<ItemType>)[];
|
||||
/**
|
||||
* Formats the elements in the array to an ordered list.
|
||||
*
|
||||
* @param list - The array of elements to list
|
||||
* @param startNumber - The starting number for the list
|
||||
*/
|
||||
declare function orderedList(list: RecursiveArray<string>, startNumber?: number): string;
|
||||
/**
|
||||
* Formats the elements in the array to an unordered list.
|
||||
*
|
||||
* @param list - The array of elements to list
|
||||
*/
|
||||
declare function unorderedList(list: RecursiveArray<string>): string;
|
||||
/**
|
||||
* Formats a date into a short date-time string.
|
||||
*
|
||||
* @param date - The date to format. Defaults to the current time
|
||||
*/
|
||||
declare function time(date?: Date): `<t:${bigint}>`;
|
||||
/**
|
||||
* Formats a date given a format style.
|
||||
*
|
||||
* @typeParam Style - This is inferred by the supplied {@link TimestampStylesString}
|
||||
* @param date - The date to format
|
||||
* @param style - The style to use
|
||||
*/
|
||||
declare function time<Style extends TimestampStylesString>(date: Date, style: Style): `<t:${bigint}:${Style}>`;
|
||||
/**
|
||||
* Formats the given timestamp into a short date-time string.
|
||||
*
|
||||
* @typeParam Seconds - This is inferred by the supplied timestamp
|
||||
* @param seconds - A Unix timestamp in seconds
|
||||
*/
|
||||
declare function time<Seconds extends number>(seconds: Seconds): `<t:${Seconds}>`;
|
||||
/**
|
||||
* Formats the given timestamp into a short date-time string.
|
||||
*
|
||||
* @typeParam Seconds - This is inferred by the supplied timestamp
|
||||
* @typeParam Style - This is inferred by the supplied {@link TimestampStylesString}
|
||||
* @param seconds - A Unix timestamp in seconds
|
||||
* @param style - The style to use
|
||||
*/
|
||||
declare function time<Seconds extends number, Style extends TimestampStylesString>(seconds: Seconds, style: Style): `<t:${Seconds}:${Style}>`;
|
||||
/**
|
||||
* The {@link https://discord.com/developers/docs/reference#message-formatting-timestamp-styles | message formatting timestamp styles}
|
||||
* supported by Discord.
|
||||
*/
|
||||
declare const TimestampStyles: {
|
||||
/**
|
||||
* Short time format, consisting of hours and minutes.
|
||||
*
|
||||
* @example `16:20`
|
||||
*/
|
||||
readonly ShortTime: "t";
|
||||
/**
|
||||
* Long time format, consisting of hours, minutes, and seconds.
|
||||
*
|
||||
* @example `16:20:30`
|
||||
*/
|
||||
readonly LongTime: "T";
|
||||
/**
|
||||
* Short date format, consisting of day, month, and year.
|
||||
*
|
||||
* @example `20/04/2021`
|
||||
*/
|
||||
readonly ShortDate: "d";
|
||||
/**
|
||||
* Long date format, consisting of day, month, and year.
|
||||
*
|
||||
* @example `20 April 2021`
|
||||
*/
|
||||
readonly LongDate: "D";
|
||||
/**
|
||||
* Short date-time format, consisting of short date and short time formats.
|
||||
*
|
||||
* @example `20 April 2021 16:20`
|
||||
*/
|
||||
readonly ShortDateTime: "f";
|
||||
/**
|
||||
* Long date-time format, consisting of long date and short time formats.
|
||||
*
|
||||
* @example `Tuesday, 20 April 2021 16:20`
|
||||
*/
|
||||
readonly LongDateTime: "F";
|
||||
/**
|
||||
* Relative time format, consisting of a relative duration format.
|
||||
*
|
||||
* @example `2 months ago`
|
||||
*/
|
||||
readonly RelativeTime: "R";
|
||||
};
|
||||
/**
|
||||
* The possible {@link TimestampStyles} values.
|
||||
*/
|
||||
type TimestampStylesString = (typeof TimestampStyles)[keyof typeof TimestampStyles];
|
||||
/**
|
||||
* All the available faces from Discord's native slash commands.
|
||||
*/
|
||||
declare enum Faces {
|
||||
/**
|
||||
* `¯\_(ツ)_/¯`
|
||||
*/
|
||||
Shrug = "\u00AF_(\u30C4)_/\u00AF",
|
||||
/**
|
||||
* `(╯°□°)╯︵ ┻━┻`
|
||||
*/
|
||||
Tableflip = "(\u256F\u00B0\u25A1\u00B0)\u256F\uFE35 \u253B\u2501\u253B",
|
||||
/**
|
||||
* `┬─┬ノ( º _ ºノ)`
|
||||
*/
|
||||
Unflip = "\u252C\u2500\u252C\u30CE( \u00BA _ \u00BA\u30CE)"
|
||||
}
|
||||
/**
|
||||
* All the available guild navigation mentions.
|
||||
*/
|
||||
declare enum GuildNavigationMentions {
|
||||
/**
|
||||
* Browse Channels tab.
|
||||
*/
|
||||
Browse = "<id:browse>",
|
||||
/**
|
||||
* Customize tab with the server's {@link https://discord.com/developers/docs/resources/guild#guild-onboarding-object | onboarding prompts}.
|
||||
*/
|
||||
Customize = "<id:customize>",
|
||||
/**
|
||||
* {@link https://support.discord.com/hc/articles/13497665141655 | Server Guide} tab.
|
||||
*/
|
||||
Guide = "<id:guide>"
|
||||
}
|
||||
|
||||
export { EscapeMarkdownOptions, Faces, GuildNavigationMentions, HeadingLevel, RecursiveArray, TimestampStyles, TimestampStylesString, blockQuote, bold, channelLink, channelMention, chatInputApplicationCommandMention, codeBlock, escapeBold, escapeBulletedList, escapeCodeBlock, escapeEscape, escapeHeading, escapeInlineCode, escapeItalic, escapeMarkdown, escapeMaskedLink, escapeNumberedList, escapeSpoiler, escapeStrikethrough, escapeUnderline, formatEmoji, heading, hideLinkEmbed, hyperlink, inlineCode, italic, messageLink, orderedList, quote, roleMention, spoiler, strikethrough, time, underscore, unorderedList, userMention };
|
586
node_modules/@discordjs/formatters/dist/index.d.ts
generated
vendored
Normal file
586
node_modules/@discordjs/formatters/dist/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,586 @@
|
|||
import { URL } from 'node:url';
|
||||
import { Snowflake } from 'discord-api-types/globals';
|
||||
|
||||
/**
|
||||
* The options that affect what will be escaped.
|
||||
*/
|
||||
interface EscapeMarkdownOptions {
|
||||
/**
|
||||
* Whether to escape bold text.
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
bold?: boolean;
|
||||
/**
|
||||
* Whether to escape bulleted lists.
|
||||
*
|
||||
* @defaultValue `false`
|
||||
*/
|
||||
bulletedList?: boolean;
|
||||
/**
|
||||
* Whether to escape code blocks.
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
codeBlock?: boolean;
|
||||
/**
|
||||
* Whether to escape text inside code blocks.
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
codeBlockContent?: boolean;
|
||||
/**
|
||||
* Whether to escape `\`.
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
escape?: boolean;
|
||||
/**
|
||||
* Whether to escape headings.
|
||||
*
|
||||
* @defaultValue `false`
|
||||
*/
|
||||
heading?: boolean;
|
||||
/**
|
||||
* Whether to escape inline code.
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
inlineCode?: boolean;
|
||||
/**
|
||||
* Whether to escape text inside inline code.
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
inlineCodeContent?: boolean;
|
||||
/**
|
||||
* Whether to escape italics.
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
italic?: boolean;
|
||||
/**
|
||||
* Whether to escape masked links.
|
||||
*
|
||||
* @defaultValue `false`
|
||||
*/
|
||||
maskedLink?: boolean;
|
||||
/**
|
||||
* Whether to escape numbered lists.
|
||||
*
|
||||
* @defaultValue `false`
|
||||
*/
|
||||
numberedList?: boolean;
|
||||
/**
|
||||
* Whether to escape spoilers.
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
spoiler?: boolean;
|
||||
/**
|
||||
* Whether to escape strikethroughs.
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
strikethrough?: boolean;
|
||||
/**
|
||||
* Whether to escape underlines.
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
underline?: boolean;
|
||||
}
|
||||
/**
|
||||
* Escapes any Discord-flavored markdown in a string.
|
||||
*
|
||||
* @param text - Content to escape
|
||||
* @param options - Options for escaping the markdown
|
||||
*/
|
||||
declare function escapeMarkdown(text: string, options?: EscapeMarkdownOptions): string;
|
||||
/**
|
||||
* Escapes code block markdown in a string.
|
||||
*
|
||||
* @param text - Content to escape
|
||||
*/
|
||||
declare function escapeCodeBlock(text: string): string;
|
||||
/**
|
||||
* Escapes inline code markdown in a string.
|
||||
*
|
||||
* @param text - Content to escape
|
||||
*/
|
||||
declare function escapeInlineCode(text: string): string;
|
||||
/**
|
||||
* Escapes italic markdown in a string.
|
||||
*
|
||||
* @param text - Content to escape
|
||||
*/
|
||||
declare function escapeItalic(text: string): string;
|
||||
/**
|
||||
* Escapes bold markdown in a string.
|
||||
*
|
||||
* @param text - Content to escape
|
||||
*/
|
||||
declare function escapeBold(text: string): string;
|
||||
/**
|
||||
* Escapes underline markdown in a string.
|
||||
*
|
||||
* @param text - Content to escape
|
||||
*/
|
||||
declare function escapeUnderline(text: string): string;
|
||||
/**
|
||||
* Escapes strikethrough markdown in a string.
|
||||
*
|
||||
* @param text - Content to escape
|
||||
*/
|
||||
declare function escapeStrikethrough(text: string): string;
|
||||
/**
|
||||
* Escapes spoiler markdown in a string.
|
||||
*
|
||||
* @param text - Content to escape
|
||||
*/
|
||||
declare function escapeSpoiler(text: string): string;
|
||||
/**
|
||||
* Escapes escape characters in a string.
|
||||
*
|
||||
* @param text - Content to escape
|
||||
*/
|
||||
declare function escapeEscape(text: string): string;
|
||||
/**
|
||||
* Escapes heading characters in a string.
|
||||
*
|
||||
* @param text - Content to escape
|
||||
*/
|
||||
declare function escapeHeading(text: string): string;
|
||||
/**
|
||||
* Escapes bulleted list characters in a string.
|
||||
*
|
||||
* @param text - Content to escape
|
||||
*/
|
||||
declare function escapeBulletedList(text: string): string;
|
||||
/**
|
||||
* Escapes numbered list characters in a string.
|
||||
*
|
||||
* @param text - Content to escape
|
||||
*/
|
||||
declare function escapeNumberedList(text: string): string;
|
||||
/**
|
||||
* Escapes masked link characters in a string.
|
||||
*
|
||||
* @param text - Content to escape
|
||||
*/
|
||||
declare function escapeMaskedLink(text: string): string;
|
||||
|
||||
/**
|
||||
* Wraps the content inside a code block with no language.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param content - The content to wrap
|
||||
*/
|
||||
declare function codeBlock<Content extends string>(content: Content): `\`\`\`\n${Content}\n\`\`\``;
|
||||
/**
|
||||
* Wraps the content inside a code block with the specified language.
|
||||
*
|
||||
* @typeParam Language - This is inferred by the supplied language
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param language - The language for the code block
|
||||
* @param content - The content to wrap
|
||||
*/
|
||||
declare function codeBlock<Language extends string, Content extends string>(language: Language, content: Content): `\`\`\`${Language}\n${Content}\n\`\`\``;
|
||||
/**
|
||||
* Wraps the content inside \`backticks\` which formats it as inline code.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param content - The content to wrap
|
||||
*/
|
||||
declare function inlineCode<Content extends string>(content: Content): `\`${Content}\``;
|
||||
/**
|
||||
* Formats the content into italic text.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param content - The content to wrap
|
||||
*/
|
||||
declare function italic<Content extends string>(content: Content): `_${Content}_`;
|
||||
/**
|
||||
* Formats the content into bold text.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param content - The content to wrap
|
||||
*/
|
||||
declare function bold<Content extends string>(content: Content): `**${Content}**`;
|
||||
/**
|
||||
* Formats the content into underscored text.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param content - The content to wrap
|
||||
*/
|
||||
declare function underscore<Content extends string>(content: Content): `__${Content}__`;
|
||||
/**
|
||||
* Formats the content into strike-through text.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param content - The content to wrap
|
||||
*/
|
||||
declare function strikethrough<Content extends string>(content: Content): `~~${Content}~~`;
|
||||
/**
|
||||
* Formats the content into a quote.
|
||||
*
|
||||
* @remarks This needs to be at the start of the line for Discord to format it.
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param content - The content to wrap
|
||||
*/
|
||||
declare function quote<Content extends string>(content: Content): `> ${Content}`;
|
||||
/**
|
||||
* Formats the content into a block quote.
|
||||
*
|
||||
* @remarks This needs to be at the start of the line for Discord to format it.
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param content - The content to wrap
|
||||
*/
|
||||
declare function blockQuote<Content extends string>(content: Content): `>>> ${Content}`;
|
||||
/**
|
||||
* Wraps the URL into `<>` which stops it from embedding.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param url - The URL to wrap
|
||||
*/
|
||||
declare function hideLinkEmbed<Content extends string>(url: Content): `<${Content}>`;
|
||||
/**
|
||||
* Wraps the URL into `<>` which stops it from embedding.
|
||||
*
|
||||
* @param url - The URL to wrap
|
||||
*/
|
||||
declare function hideLinkEmbed(url: URL): `<${string}>`;
|
||||
/**
|
||||
* Formats the content and the URL into a masked URL.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param content - The content to display
|
||||
* @param url - The URL the content links to
|
||||
*/
|
||||
declare function hyperlink<Content extends string>(content: Content, url: URL): `[${Content}](${string})`;
|
||||
/**
|
||||
* Formats the content and the URL into a masked URL.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @typeParam Url - This is inferred by the supplied URL
|
||||
* @param content - The content to display
|
||||
* @param url - The URL the content links to
|
||||
*/
|
||||
declare function hyperlink<Content extends string, Url extends string>(content: Content, url: Url): `[${Content}](${Url})`;
|
||||
/**
|
||||
* Formats the content and the URL into a masked URL with a custom tooltip.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @typeParam Title - This is inferred by the supplied title
|
||||
* @param content - The content to display
|
||||
* @param url - The URL the content links to
|
||||
* @param title - The title shown when hovering on the masked link
|
||||
*/
|
||||
declare function hyperlink<Content extends string, Title extends string>(content: Content, url: URL, title: Title): `[${Content}](${string} "${Title}")`;
|
||||
/**
|
||||
* Formats the content and the URL into a masked URL with a custom tooltip.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @typeParam Url - This is inferred by the supplied URL
|
||||
* @typeParam Title - This is inferred by the supplied title
|
||||
* @param content - The content to display
|
||||
* @param url - The URL the content links to
|
||||
* @param title - The title shown when hovering on the masked link
|
||||
*/
|
||||
declare function hyperlink<Content extends string, Url extends string, Title extends string>(content: Content, url: Url, title: Title): `[${Content}](${Url} "${Title}")`;
|
||||
/**
|
||||
* Formats the content into a spoiler.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param content - The content to wrap
|
||||
*/
|
||||
declare function spoiler<Content extends string>(content: Content): `||${Content}||`;
|
||||
/**
|
||||
* Formats a user id into a user mention.
|
||||
*
|
||||
* @typeParam UserId - This is inferred by the supplied user id
|
||||
* @param userId - The user id to format
|
||||
*/
|
||||
declare function userMention<UserId extends Snowflake>(userId: UserId): `<@${UserId}>`;
|
||||
/**
|
||||
* Formats a channel id into a channel mention.
|
||||
*
|
||||
* @typeParam ChannelId - This is inferred by the supplied channel id
|
||||
* @param channelId - The channel id to format
|
||||
*/
|
||||
declare function channelMention<ChannelId extends Snowflake>(channelId: ChannelId): `<#${ChannelId}>`;
|
||||
/**
|
||||
* Formats a role id into a role mention.
|
||||
*
|
||||
* @typeParam RoleId - This is inferred by the supplied role id
|
||||
* @param roleId - The role id to format
|
||||
*/
|
||||
declare function roleMention<RoleId extends Snowflake>(roleId: RoleId): `<@&${RoleId}>`;
|
||||
/**
|
||||
* Formats an application command name, subcommand group name, subcommand name, and id into an application command mention.
|
||||
*
|
||||
* @typeParam CommandName - This is inferred by the supplied command name
|
||||
* @typeParam SubcommandGroupName - This is inferred by the supplied subcommand group name
|
||||
* @typeParam SubcommandName - This is inferred by the supplied subcommand name
|
||||
* @typeParam CommandId - This is inferred by the supplied command id
|
||||
* @param commandName - The application command name to format
|
||||
* @param subcommandGroupName - The subcommand group name to format
|
||||
* @param subcommandName - The subcommand name to format
|
||||
* @param commandId - The application command id to format
|
||||
*/
|
||||
declare function chatInputApplicationCommandMention<CommandName extends string, SubcommandGroupName extends string, SubcommandName extends string, CommandId extends Snowflake>(commandName: CommandName, subcommandGroupName: SubcommandGroupName, subcommandName: SubcommandName, commandId: CommandId): `</${CommandName} ${SubcommandGroupName} ${SubcommandName}:${CommandId}>`;
|
||||
/**
|
||||
* Formats an application command name, subcommand name, and id into an application command mention.
|
||||
*
|
||||
* @typeParam CommandName - This is inferred by the supplied command name
|
||||
* @typeParam SubcommandName - This is inferred by the supplied subcommand name
|
||||
* @typeParam CommandId - This is inferred by the supplied command id
|
||||
* @param commandName - The application command name to format
|
||||
* @param subcommandName - The subcommand name to format
|
||||
* @param commandId - The application command id to format
|
||||
*/
|
||||
declare function chatInputApplicationCommandMention<CommandName extends string, SubcommandName extends string, CommandId extends Snowflake>(commandName: CommandName, subcommandName: SubcommandName, commandId: CommandId): `</${CommandName} ${SubcommandName}:${CommandId}>`;
|
||||
/**
|
||||
* Formats an application command name and id into an application command mention.
|
||||
*
|
||||
* @typeParam CommandName - This is inferred by the supplied command name
|
||||
* @typeParam CommandId - This is inferred by the supplied command id
|
||||
* @param commandName - The application command name to format
|
||||
* @param commandId - The application command id to format
|
||||
*/
|
||||
declare function chatInputApplicationCommandMention<CommandName extends string, CommandId extends Snowflake>(commandName: CommandName, commandId: CommandId): `</${CommandName}:${CommandId}>`;
|
||||
/**
|
||||
* Formats a non-animated emoji id into a fully qualified emoji identifier.
|
||||
*
|
||||
* @typeParam EmojiId - This is inferred by the supplied emoji id
|
||||
* @param emojiId - The emoji id to format
|
||||
*/
|
||||
declare function formatEmoji<EmojiId extends Snowflake>(emojiId: EmojiId, animated?: false): `<:_:${EmojiId}>`;
|
||||
/**
|
||||
* Formats an animated emoji id into a fully qualified emoji identifier.
|
||||
*
|
||||
* @typeParam EmojiId - This is inferred by the supplied emoji id
|
||||
* @param emojiId - The emoji id to format
|
||||
* @param animated - Whether the emoji is animated
|
||||
*/
|
||||
declare function formatEmoji<EmojiId extends Snowflake>(emojiId: EmojiId, animated?: true): `<a:_:${EmojiId}>`;
|
||||
/**
|
||||
* Formats an emoji id into a fully qualified emoji identifier.
|
||||
*
|
||||
* @typeParam EmojiId - This is inferred by the supplied emoji id
|
||||
* @param emojiId - The emoji id to format
|
||||
* @param animated - Whether the emoji is animated
|
||||
*/
|
||||
declare function formatEmoji<EmojiId extends Snowflake>(emojiId: EmojiId, animated?: boolean): `<:_:${EmojiId}>` | `<a:_:${EmojiId}>`;
|
||||
/**
|
||||
* Formats a channel link for a direct message channel.
|
||||
*
|
||||
* @typeParam ChannelId - This is inferred by the supplied channel id
|
||||
* @param channelId - The channel's id
|
||||
*/
|
||||
declare function channelLink<ChannelId extends Snowflake>(channelId: ChannelId): `https://discord.com/channels/@me/${ChannelId}`;
|
||||
/**
|
||||
* Formats a channel link for a guild channel.
|
||||
*
|
||||
* @typeParam ChannelId - This is inferred by the supplied channel id
|
||||
* @typeParam GuildId - This is inferred by the supplied guild id
|
||||
* @param channelId - The channel's id
|
||||
* @param guildId - The guild's id
|
||||
*/
|
||||
declare function channelLink<ChannelId extends Snowflake, GuildId extends Snowflake>(channelId: ChannelId, guildId: GuildId): `https://discord.com/channels/${GuildId}/${ChannelId}`;
|
||||
/**
|
||||
* Formats a message link for a direct message channel.
|
||||
*
|
||||
* @typeParam ChannelId - This is inferred by the supplied channel id
|
||||
* @typeParam MessageId - This is inferred by the supplied message id
|
||||
* @param channelId - The channel's id
|
||||
* @param messageId - The message's id
|
||||
*/
|
||||
declare function messageLink<ChannelId extends Snowflake, MessageId extends Snowflake>(channelId: ChannelId, messageId: MessageId): `https://discord.com/channels/@me/${ChannelId}/${MessageId}`;
|
||||
/**
|
||||
* Formats a message link for a guild channel.
|
||||
*
|
||||
* @typeParam ChannelId - This is inferred by the supplied channel id
|
||||
* @typeParam MessageId - This is inferred by the supplied message id
|
||||
* @typeParam GuildId - This is inferred by the supplied guild id
|
||||
* @param channelId - The channel's id
|
||||
* @param messageId - The message's id
|
||||
* @param guildId - The guild's id
|
||||
*/
|
||||
declare function messageLink<ChannelId extends Snowflake, MessageId extends Snowflake, GuildId extends Snowflake>(channelId: ChannelId, messageId: MessageId, guildId: GuildId): `https://discord.com/channels/${GuildId}/${ChannelId}/${MessageId}`;
|
||||
/**
|
||||
* The heading levels for expanded markdown.
|
||||
*/
|
||||
declare enum HeadingLevel {
|
||||
/**
|
||||
* The first heading level.
|
||||
*/
|
||||
One = 1,
|
||||
/**
|
||||
* The second heading level.
|
||||
*/
|
||||
Two = 2,
|
||||
/**
|
||||
* The third heading level.
|
||||
*/
|
||||
Three = 3
|
||||
}
|
||||
/**
|
||||
* Formats the content into a heading level.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param content - The content to wrap
|
||||
* @param level - The heading level
|
||||
*/
|
||||
declare function heading<Content extends string>(content: Content, level?: HeadingLevel.One): `# ${Content}`;
|
||||
/**
|
||||
* Formats the content into a heading level.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param content - The content to wrap
|
||||
* @param level - The heading level
|
||||
*/
|
||||
declare function heading<Content extends string>(content: Content, level: HeadingLevel.Two): `## ${Content}`;
|
||||
/**
|
||||
* Formats the content into a heading level.
|
||||
*
|
||||
* @typeParam Content - This is inferred by the supplied content
|
||||
* @param content - The content to wrap
|
||||
* @param level - The heading level
|
||||
*/
|
||||
declare function heading<Content extends string>(content: Content, level: HeadingLevel.Three): `### ${Content}`;
|
||||
/**
|
||||
* A type that recursively traverses into arrays.
|
||||
*/
|
||||
type RecursiveArray<ItemType> = readonly (ItemType | RecursiveArray<ItemType>)[];
|
||||
/**
|
||||
* Formats the elements in the array to an ordered list.
|
||||
*
|
||||
* @param list - The array of elements to list
|
||||
* @param startNumber - The starting number for the list
|
||||
*/
|
||||
declare function orderedList(list: RecursiveArray<string>, startNumber?: number): string;
|
||||
/**
|
||||
* Formats the elements in the array to an unordered list.
|
||||
*
|
||||
* @param list - The array of elements to list
|
||||
*/
|
||||
declare function unorderedList(list: RecursiveArray<string>): string;
|
||||
/**
|
||||
* Formats a date into a short date-time string.
|
||||
*
|
||||
* @param date - The date to format. Defaults to the current time
|
||||
*/
|
||||
declare function time(date?: Date): `<t:${bigint}>`;
|
||||
/**
|
||||
* Formats a date given a format style.
|
||||
*
|
||||
* @typeParam Style - This is inferred by the supplied {@link TimestampStylesString}
|
||||
* @param date - The date to format
|
||||
* @param style - The style to use
|
||||
*/
|
||||
declare function time<Style extends TimestampStylesString>(date: Date, style: Style): `<t:${bigint}:${Style}>`;
|
||||
/**
|
||||
* Formats the given timestamp into a short date-time string.
|
||||
*
|
||||
* @typeParam Seconds - This is inferred by the supplied timestamp
|
||||
* @param seconds - A Unix timestamp in seconds
|
||||
*/
|
||||
declare function time<Seconds extends number>(seconds: Seconds): `<t:${Seconds}>`;
|
||||
/**
|
||||
* Formats the given timestamp into a short date-time string.
|
||||
*
|
||||
* @typeParam Seconds - This is inferred by the supplied timestamp
|
||||
* @typeParam Style - This is inferred by the supplied {@link TimestampStylesString}
|
||||
* @param seconds - A Unix timestamp in seconds
|
||||
* @param style - The style to use
|
||||
*/
|
||||
declare function time<Seconds extends number, Style extends TimestampStylesString>(seconds: Seconds, style: Style): `<t:${Seconds}:${Style}>`;
|
||||
/**
|
||||
* The {@link https://discord.com/developers/docs/reference#message-formatting-timestamp-styles | message formatting timestamp styles}
|
||||
* supported by Discord.
|
||||
*/
|
||||
declare const TimestampStyles: {
|
||||
/**
|
||||
* Short time format, consisting of hours and minutes.
|
||||
*
|
||||
* @example `16:20`
|
||||
*/
|
||||
readonly ShortTime: "t";
|
||||
/**
|
||||
* Long time format, consisting of hours, minutes, and seconds.
|
||||
*
|
||||
* @example `16:20:30`
|
||||
*/
|
||||
readonly LongTime: "T";
|
||||
/**
|
||||
* Short date format, consisting of day, month, and year.
|
||||
*
|
||||
* @example `20/04/2021`
|
||||
*/
|
||||
readonly ShortDate: "d";
|
||||
/**
|
||||
* Long date format, consisting of day, month, and year.
|
||||
*
|
||||
* @example `20 April 2021`
|
||||
*/
|
||||
readonly LongDate: "D";
|
||||
/**
|
||||
* Short date-time format, consisting of short date and short time formats.
|
||||
*
|
||||
* @example `20 April 2021 16:20`
|
||||
*/
|
||||
readonly ShortDateTime: "f";
|
||||
/**
|
||||
* Long date-time format, consisting of long date and short time formats.
|
||||
*
|
||||
* @example `Tuesday, 20 April 2021 16:20`
|
||||
*/
|
||||
readonly LongDateTime: "F";
|
||||
/**
|
||||
* Relative time format, consisting of a relative duration format.
|
||||
*
|
||||
* @example `2 months ago`
|
||||
*/
|
||||
readonly RelativeTime: "R";
|
||||
};
|
||||
/**
|
||||
* The possible {@link TimestampStyles} values.
|
||||
*/
|
||||
type TimestampStylesString = (typeof TimestampStyles)[keyof typeof TimestampStyles];
|
||||
/**
|
||||
* All the available faces from Discord's native slash commands.
|
||||
*/
|
||||
declare enum Faces {
|
||||
/**
|
||||
* `¯\_(ツ)_/¯`
|
||||
*/
|
||||
Shrug = "\u00AF_(\u30C4)_/\u00AF",
|
||||
/**
|
||||
* `(╯°□°)╯︵ ┻━┻`
|
||||
*/
|
||||
Tableflip = "(\u256F\u00B0\u25A1\u00B0)\u256F\uFE35 \u253B\u2501\u253B",
|
||||
/**
|
||||
* `┬─┬ノ( º _ ºノ)`
|
||||
*/
|
||||
Unflip = "\u252C\u2500\u252C\u30CE( \u00BA _ \u00BA\u30CE)"
|
||||
}
|
||||
/**
|
||||
* All the available guild navigation mentions.
|
||||
*/
|
||||
declare enum GuildNavigationMentions {
|
||||
/**
|
||||
* Browse Channels tab.
|
||||
*/
|
||||
Browse = "<id:browse>",
|
||||
/**
|
||||
* Customize tab with the server's {@link https://discord.com/developers/docs/resources/guild#guild-onboarding-object | onboarding prompts}.
|
||||
*/
|
||||
Customize = "<id:customize>",
|
||||
/**
|
||||
* {@link https://support.discord.com/hc/articles/13497665141655 | Server Guide} tab.
|
||||
*/
|
||||
Guide = "<id:guide>"
|
||||
}
|
||||
|
||||
export { EscapeMarkdownOptions, Faces, GuildNavigationMentions, HeadingLevel, RecursiveArray, TimestampStyles, TimestampStylesString, blockQuote, bold, channelLink, channelMention, chatInputApplicationCommandMention, codeBlock, escapeBold, escapeBulletedList, escapeCodeBlock, escapeEscape, escapeHeading, escapeInlineCode, escapeItalic, escapeMarkdown, escapeMaskedLink, escapeNumberedList, escapeSpoiler, escapeStrikethrough, escapeUnderline, formatEmoji, heading, hideLinkEmbed, hyperlink, inlineCode, italic, messageLink, orderedList, quote, roleMention, spoiler, strikethrough, time, underscore, unorderedList, userMention };
|
441
node_modules/@discordjs/formatters/dist/index.js
generated
vendored
Normal file
441
node_modules/@discordjs/formatters/dist/index.js
generated
vendored
Normal file
|
@ -0,0 +1,441 @@
|
|||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/index.ts
|
||||
var src_exports = {};
|
||||
__export(src_exports, {
|
||||
Faces: () => Faces,
|
||||
GuildNavigationMentions: () => GuildNavigationMentions,
|
||||
HeadingLevel: () => HeadingLevel,
|
||||
TimestampStyles: () => TimestampStyles,
|
||||
blockQuote: () => blockQuote,
|
||||
bold: () => bold,
|
||||
channelLink: () => channelLink,
|
||||
channelMention: () => channelMention,
|
||||
chatInputApplicationCommandMention: () => chatInputApplicationCommandMention,
|
||||
codeBlock: () => codeBlock,
|
||||
escapeBold: () => escapeBold,
|
||||
escapeBulletedList: () => escapeBulletedList,
|
||||
escapeCodeBlock: () => escapeCodeBlock,
|
||||
escapeEscape: () => escapeEscape,
|
||||
escapeHeading: () => escapeHeading,
|
||||
escapeInlineCode: () => escapeInlineCode,
|
||||
escapeItalic: () => escapeItalic,
|
||||
escapeMarkdown: () => escapeMarkdown,
|
||||
escapeMaskedLink: () => escapeMaskedLink,
|
||||
escapeNumberedList: () => escapeNumberedList,
|
||||
escapeSpoiler: () => escapeSpoiler,
|
||||
escapeStrikethrough: () => escapeStrikethrough,
|
||||
escapeUnderline: () => escapeUnderline,
|
||||
formatEmoji: () => formatEmoji,
|
||||
heading: () => heading,
|
||||
hideLinkEmbed: () => hideLinkEmbed,
|
||||
hyperlink: () => hyperlink,
|
||||
inlineCode: () => inlineCode,
|
||||
italic: () => italic,
|
||||
messageLink: () => messageLink,
|
||||
orderedList: () => orderedList,
|
||||
quote: () => quote,
|
||||
roleMention: () => roleMention,
|
||||
spoiler: () => spoiler,
|
||||
strikethrough: () => strikethrough,
|
||||
time: () => time,
|
||||
underscore: () => underscore,
|
||||
unorderedList: () => unorderedList,
|
||||
userMention: () => userMention
|
||||
});
|
||||
module.exports = __toCommonJS(src_exports);
|
||||
|
||||
// src/escapers.ts
|
||||
function escapeMarkdown(text, options = {}) {
|
||||
const {
|
||||
codeBlock: codeBlock2 = true,
|
||||
inlineCode: inlineCode2 = true,
|
||||
bold: bold2 = true,
|
||||
italic: italic2 = true,
|
||||
underline = true,
|
||||
strikethrough: strikethrough2 = true,
|
||||
spoiler: spoiler2 = true,
|
||||
codeBlockContent = true,
|
||||
inlineCodeContent = true,
|
||||
escape = true,
|
||||
heading: heading2 = false,
|
||||
bulletedList = false,
|
||||
numberedList = false,
|
||||
maskedLink = false
|
||||
} = options;
|
||||
if (!codeBlockContent) {
|
||||
return text.split("```").map((subString, index, array) => {
|
||||
if (index % 2 && index !== array.length - 1)
|
||||
return subString;
|
||||
return escapeMarkdown(subString, {
|
||||
inlineCode: inlineCode2,
|
||||
bold: bold2,
|
||||
italic: italic2,
|
||||
underline,
|
||||
strikethrough: strikethrough2,
|
||||
spoiler: spoiler2,
|
||||
inlineCodeContent,
|
||||
escape,
|
||||
heading: heading2,
|
||||
bulletedList,
|
||||
numberedList,
|
||||
maskedLink
|
||||
});
|
||||
}).join(codeBlock2 ? "\\`\\`\\`" : "```");
|
||||
}
|
||||
if (!inlineCodeContent) {
|
||||
return text.split(/(?<=^|[^`])`(?=[^`]|$)/g).map((subString, index, array) => {
|
||||
if (index % 2 && index !== array.length - 1)
|
||||
return subString;
|
||||
return escapeMarkdown(subString, {
|
||||
codeBlock: codeBlock2,
|
||||
bold: bold2,
|
||||
italic: italic2,
|
||||
underline,
|
||||
strikethrough: strikethrough2,
|
||||
spoiler: spoiler2,
|
||||
escape,
|
||||
heading: heading2,
|
||||
bulletedList,
|
||||
numberedList,
|
||||
maskedLink
|
||||
});
|
||||
}).join(inlineCode2 ? "\\`" : "`");
|
||||
}
|
||||
let res = text;
|
||||
if (escape)
|
||||
res = escapeEscape(res);
|
||||
if (inlineCode2)
|
||||
res = escapeInlineCode(res);
|
||||
if (codeBlock2)
|
||||
res = escapeCodeBlock(res);
|
||||
if (italic2)
|
||||
res = escapeItalic(res);
|
||||
if (bold2)
|
||||
res = escapeBold(res);
|
||||
if (underline)
|
||||
res = escapeUnderline(res);
|
||||
if (strikethrough2)
|
||||
res = escapeStrikethrough(res);
|
||||
if (spoiler2)
|
||||
res = escapeSpoiler(res);
|
||||
if (heading2)
|
||||
res = escapeHeading(res);
|
||||
if (bulletedList)
|
||||
res = escapeBulletedList(res);
|
||||
if (numberedList)
|
||||
res = escapeNumberedList(res);
|
||||
if (maskedLink)
|
||||
res = escapeMaskedLink(res);
|
||||
return res;
|
||||
}
|
||||
__name(escapeMarkdown, "escapeMarkdown");
|
||||
function escapeCodeBlock(text) {
|
||||
return text.replaceAll("```", "\\`\\`\\`");
|
||||
}
|
||||
__name(escapeCodeBlock, "escapeCodeBlock");
|
||||
function escapeInlineCode(text) {
|
||||
return text.replaceAll(/(?<=^|[^`])``?(?=[^`]|$)/g, (match) => match.length === 2 ? "\\`\\`" : "\\`");
|
||||
}
|
||||
__name(escapeInlineCode, "escapeInlineCode");
|
||||
function escapeItalic(text) {
|
||||
let idx = 0;
|
||||
const newText = text.replaceAll(/(?<=^|[^*])\*([^*]|\*\*|$)/g, (_, match) => {
|
||||
if (match === "**")
|
||||
return ++idx % 2 ? `\\*${match}` : `${match}\\*`;
|
||||
return `\\*${match}`;
|
||||
});
|
||||
idx = 0;
|
||||
return newText.replaceAll(/(?<=^|[^_])(?<!<a?:.+)_(?!:\d+>)([^_]|__|$)/g, (_, match) => {
|
||||
if (match === "__")
|
||||
return ++idx % 2 ? `\\_${match}` : `${match}\\_`;
|
||||
return `\\_${match}`;
|
||||
});
|
||||
}
|
||||
__name(escapeItalic, "escapeItalic");
|
||||
function escapeBold(text) {
|
||||
let idx = 0;
|
||||
return text.replaceAll(/\*\*(\*)?/g, (_, match) => {
|
||||
if (match)
|
||||
return ++idx % 2 ? `${match}\\*\\*` : `\\*\\*${match}`;
|
||||
return "\\*\\*";
|
||||
});
|
||||
}
|
||||
__name(escapeBold, "escapeBold");
|
||||
function escapeUnderline(text) {
|
||||
let idx = 0;
|
||||
return text.replaceAll(/(?<!<a?:.+)__(_)?(?!:\d+>)/g, (_, match) => {
|
||||
if (match)
|
||||
return ++idx % 2 ? `${match}\\_\\_` : `\\_\\_${match}`;
|
||||
return "\\_\\_";
|
||||
});
|
||||
}
|
||||
__name(escapeUnderline, "escapeUnderline");
|
||||
function escapeStrikethrough(text) {
|
||||
return text.replaceAll("~~", "\\~\\~");
|
||||
}
|
||||
__name(escapeStrikethrough, "escapeStrikethrough");
|
||||
function escapeSpoiler(text) {
|
||||
return text.replaceAll("||", "\\|\\|");
|
||||
}
|
||||
__name(escapeSpoiler, "escapeSpoiler");
|
||||
function escapeEscape(text) {
|
||||
return text.replaceAll("\\", "\\\\");
|
||||
}
|
||||
__name(escapeEscape, "escapeEscape");
|
||||
function escapeHeading(text) {
|
||||
return text.replaceAll(/^( {0,2})([*-] )?( *)(#{1,3} )/gm, "$1$2$3\\$4");
|
||||
}
|
||||
__name(escapeHeading, "escapeHeading");
|
||||
function escapeBulletedList(text) {
|
||||
return text.replaceAll(/^( *)([*-])( +)/gm, "$1\\$2$3");
|
||||
}
|
||||
__name(escapeBulletedList, "escapeBulletedList");
|
||||
function escapeNumberedList(text) {
|
||||
return text.replaceAll(/^( *\d+)\./gm, "$1\\.");
|
||||
}
|
||||
__name(escapeNumberedList, "escapeNumberedList");
|
||||
function escapeMaskedLink(text) {
|
||||
return text.replaceAll(/\[.+]\(.+\)/gm, "\\$&");
|
||||
}
|
||||
__name(escapeMaskedLink, "escapeMaskedLink");
|
||||
|
||||
// src/formatters.ts
|
||||
function codeBlock(language, content) {
|
||||
return content === void 0 ? `\`\`\`
|
||||
${language}
|
||||
\`\`\`` : `\`\`\`${language}
|
||||
${content}
|
||||
\`\`\``;
|
||||
}
|
||||
__name(codeBlock, "codeBlock");
|
||||
function inlineCode(content) {
|
||||
return `\`${content}\``;
|
||||
}
|
||||
__name(inlineCode, "inlineCode");
|
||||
function italic(content) {
|
||||
return `_${content}_`;
|
||||
}
|
||||
__name(italic, "italic");
|
||||
function bold(content) {
|
||||
return `**${content}**`;
|
||||
}
|
||||
__name(bold, "bold");
|
||||
function underscore(content) {
|
||||
return `__${content}__`;
|
||||
}
|
||||
__name(underscore, "underscore");
|
||||
function strikethrough(content) {
|
||||
return `~~${content}~~`;
|
||||
}
|
||||
__name(strikethrough, "strikethrough");
|
||||
function quote(content) {
|
||||
return `> ${content}`;
|
||||
}
|
||||
__name(quote, "quote");
|
||||
function blockQuote(content) {
|
||||
return `>>> ${content}`;
|
||||
}
|
||||
__name(blockQuote, "blockQuote");
|
||||
function hideLinkEmbed(url) {
|
||||
return `<${url}>`;
|
||||
}
|
||||
__name(hideLinkEmbed, "hideLinkEmbed");
|
||||
function hyperlink(content, url, title) {
|
||||
return title ? `[${content}](${url} "${title}")` : `[${content}](${url})`;
|
||||
}
|
||||
__name(hyperlink, "hyperlink");
|
||||
function spoiler(content) {
|
||||
return `||${content}||`;
|
||||
}
|
||||
__name(spoiler, "spoiler");
|
||||
function userMention(userId) {
|
||||
return `<@${userId}>`;
|
||||
}
|
||||
__name(userMention, "userMention");
|
||||
function channelMention(channelId) {
|
||||
return `<#${channelId}>`;
|
||||
}
|
||||
__name(channelMention, "channelMention");
|
||||
function roleMention(roleId) {
|
||||
return `<@&${roleId}>`;
|
||||
}
|
||||
__name(roleMention, "roleMention");
|
||||
function chatInputApplicationCommandMention(commandName, subcommandGroupName, subcommandName, commandId) {
|
||||
if (commandId !== void 0) {
|
||||
return `</${commandName} ${subcommandGroupName} ${subcommandName}:${commandId}>`;
|
||||
}
|
||||
if (subcommandName !== void 0) {
|
||||
return `</${commandName} ${subcommandGroupName}:${subcommandName}>`;
|
||||
}
|
||||
return `</${commandName}:${subcommandGroupName}>`;
|
||||
}
|
||||
__name(chatInputApplicationCommandMention, "chatInputApplicationCommandMention");
|
||||
function formatEmoji(emojiId, animated = false) {
|
||||
return `<${animated ? "a" : ""}:_:${emojiId}>`;
|
||||
}
|
||||
__name(formatEmoji, "formatEmoji");
|
||||
function channelLink(channelId, guildId) {
|
||||
return `https://discord.com/channels/${guildId ?? "@me"}/${channelId}`;
|
||||
}
|
||||
__name(channelLink, "channelLink");
|
||||
function messageLink(channelId, messageId, guildId) {
|
||||
return `${guildId === void 0 ? channelLink(channelId) : channelLink(channelId, guildId)}/${messageId}`;
|
||||
}
|
||||
__name(messageLink, "messageLink");
|
||||
var HeadingLevel = /* @__PURE__ */ ((HeadingLevel2) => {
|
||||
HeadingLevel2[HeadingLevel2["One"] = 1] = "One";
|
||||
HeadingLevel2[HeadingLevel2["Two"] = 2] = "Two";
|
||||
HeadingLevel2[HeadingLevel2["Three"] = 3] = "Three";
|
||||
return HeadingLevel2;
|
||||
})(HeadingLevel || {});
|
||||
function heading(content, level) {
|
||||
switch (level) {
|
||||
case 3 /* Three */:
|
||||
return `### ${content}`;
|
||||
case 2 /* Two */:
|
||||
return `## ${content}`;
|
||||
default:
|
||||
return `# ${content}`;
|
||||
}
|
||||
}
|
||||
__name(heading, "heading");
|
||||
function listCallback(element, startNumber, depth = 0) {
|
||||
if (Array.isArray(element)) {
|
||||
return element.map((element2) => listCallback(element2, startNumber, depth + 1)).join("\n");
|
||||
}
|
||||
return `${" ".repeat(depth - 1)}${startNumber ? `${startNumber}.` : "-"} ${element}`;
|
||||
}
|
||||
__name(listCallback, "listCallback");
|
||||
function orderedList(list, startNumber = 1) {
|
||||
return listCallback(list, Math.max(startNumber, 1));
|
||||
}
|
||||
__name(orderedList, "orderedList");
|
||||
function unorderedList(list) {
|
||||
return listCallback(list);
|
||||
}
|
||||
__name(unorderedList, "unorderedList");
|
||||
function time(timeOrSeconds, style) {
|
||||
if (typeof timeOrSeconds !== "number") {
|
||||
timeOrSeconds = Math.floor((timeOrSeconds?.getTime() ?? Date.now()) / 1e3);
|
||||
}
|
||||
return typeof style === "string" ? `<t:${timeOrSeconds}:${style}>` : `<t:${timeOrSeconds}>`;
|
||||
}
|
||||
__name(time, "time");
|
||||
var TimestampStyles = {
|
||||
/**
|
||||
* Short time format, consisting of hours and minutes.
|
||||
*
|
||||
* @example `16:20`
|
||||
*/
|
||||
ShortTime: "t",
|
||||
/**
|
||||
* Long time format, consisting of hours, minutes, and seconds.
|
||||
*
|
||||
* @example `16:20:30`
|
||||
*/
|
||||
LongTime: "T",
|
||||
/**
|
||||
* Short date format, consisting of day, month, and year.
|
||||
*
|
||||
* @example `20/04/2021`
|
||||
*/
|
||||
ShortDate: "d",
|
||||
/**
|
||||
* Long date format, consisting of day, month, and year.
|
||||
*
|
||||
* @example `20 April 2021`
|
||||
*/
|
||||
LongDate: "D",
|
||||
/**
|
||||
* Short date-time format, consisting of short date and short time formats.
|
||||
*
|
||||
* @example `20 April 2021 16:20`
|
||||
*/
|
||||
ShortDateTime: "f",
|
||||
/**
|
||||
* Long date-time format, consisting of long date and short time formats.
|
||||
*
|
||||
* @example `Tuesday, 20 April 2021 16:20`
|
||||
*/
|
||||
LongDateTime: "F",
|
||||
/**
|
||||
* Relative time format, consisting of a relative duration format.
|
||||
*
|
||||
* @example `2 months ago`
|
||||
*/
|
||||
RelativeTime: "R"
|
||||
};
|
||||
var Faces = /* @__PURE__ */ ((Faces2) => {
|
||||
Faces2["Shrug"] = "\xAF_(\u30C4)_/\xAF";
|
||||
Faces2["Tableflip"] = "(\u256F\xB0\u25A1\xB0)\u256F\uFE35 \u253B\u2501\u253B";
|
||||
Faces2["Unflip"] = "\u252C\u2500\u252C\u30CE( \xBA _ \xBA\u30CE)";
|
||||
return Faces2;
|
||||
})(Faces || {});
|
||||
var GuildNavigationMentions = /* @__PURE__ */ ((GuildNavigationMentions2) => {
|
||||
GuildNavigationMentions2["Browse"] = "<id:browse>";
|
||||
GuildNavigationMentions2["Customize"] = "<id:customize>";
|
||||
GuildNavigationMentions2["Guide"] = "<id:guide>";
|
||||
return GuildNavigationMentions2;
|
||||
})(GuildNavigationMentions || {});
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
Faces,
|
||||
GuildNavigationMentions,
|
||||
HeadingLevel,
|
||||
TimestampStyles,
|
||||
blockQuote,
|
||||
bold,
|
||||
channelLink,
|
||||
channelMention,
|
||||
chatInputApplicationCommandMention,
|
||||
codeBlock,
|
||||
escapeBold,
|
||||
escapeBulletedList,
|
||||
escapeCodeBlock,
|
||||
escapeEscape,
|
||||
escapeHeading,
|
||||
escapeInlineCode,
|
||||
escapeItalic,
|
||||
escapeMarkdown,
|
||||
escapeMaskedLink,
|
||||
escapeNumberedList,
|
||||
escapeSpoiler,
|
||||
escapeStrikethrough,
|
||||
escapeUnderline,
|
||||
formatEmoji,
|
||||
heading,
|
||||
hideLinkEmbed,
|
||||
hyperlink,
|
||||
inlineCode,
|
||||
italic,
|
||||
messageLink,
|
||||
orderedList,
|
||||
quote,
|
||||
roleMention,
|
||||
spoiler,
|
||||
strikethrough,
|
||||
time,
|
||||
underscore,
|
||||
unorderedList,
|
||||
userMention
|
||||
});
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@discordjs/formatters/dist/index.js.map
generated
vendored
Normal file
1
node_modules/@discordjs/formatters/dist/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
378
node_modules/@discordjs/formatters/dist/index.mjs
generated
vendored
Normal file
378
node_modules/@discordjs/formatters/dist/index.mjs
generated
vendored
Normal file
|
@ -0,0 +1,378 @@
|
|||
var __defProp = Object.defineProperty;
|
||||
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
||||
|
||||
// src/escapers.ts
|
||||
function escapeMarkdown(text, options = {}) {
|
||||
const {
|
||||
codeBlock: codeBlock2 = true,
|
||||
inlineCode: inlineCode2 = true,
|
||||
bold: bold2 = true,
|
||||
italic: italic2 = true,
|
||||
underline = true,
|
||||
strikethrough: strikethrough2 = true,
|
||||
spoiler: spoiler2 = true,
|
||||
codeBlockContent = true,
|
||||
inlineCodeContent = true,
|
||||
escape = true,
|
||||
heading: heading2 = false,
|
||||
bulletedList = false,
|
||||
numberedList = false,
|
||||
maskedLink = false
|
||||
} = options;
|
||||
if (!codeBlockContent) {
|
||||
return text.split("```").map((subString, index, array) => {
|
||||
if (index % 2 && index !== array.length - 1)
|
||||
return subString;
|
||||
return escapeMarkdown(subString, {
|
||||
inlineCode: inlineCode2,
|
||||
bold: bold2,
|
||||
italic: italic2,
|
||||
underline,
|
||||
strikethrough: strikethrough2,
|
||||
spoiler: spoiler2,
|
||||
inlineCodeContent,
|
||||
escape,
|
||||
heading: heading2,
|
||||
bulletedList,
|
||||
numberedList,
|
||||
maskedLink
|
||||
});
|
||||
}).join(codeBlock2 ? "\\`\\`\\`" : "```");
|
||||
}
|
||||
if (!inlineCodeContent) {
|
||||
return text.split(/(?<=^|[^`])`(?=[^`]|$)/g).map((subString, index, array) => {
|
||||
if (index % 2 && index !== array.length - 1)
|
||||
return subString;
|
||||
return escapeMarkdown(subString, {
|
||||
codeBlock: codeBlock2,
|
||||
bold: bold2,
|
||||
italic: italic2,
|
||||
underline,
|
||||
strikethrough: strikethrough2,
|
||||
spoiler: spoiler2,
|
||||
escape,
|
||||
heading: heading2,
|
||||
bulletedList,
|
||||
numberedList,
|
||||
maskedLink
|
||||
});
|
||||
}).join(inlineCode2 ? "\\`" : "`");
|
||||
}
|
||||
let res = text;
|
||||
if (escape)
|
||||
res = escapeEscape(res);
|
||||
if (inlineCode2)
|
||||
res = escapeInlineCode(res);
|
||||
if (codeBlock2)
|
||||
res = escapeCodeBlock(res);
|
||||
if (italic2)
|
||||
res = escapeItalic(res);
|
||||
if (bold2)
|
||||
res = escapeBold(res);
|
||||
if (underline)
|
||||
res = escapeUnderline(res);
|
||||
if (strikethrough2)
|
||||
res = escapeStrikethrough(res);
|
||||
if (spoiler2)
|
||||
res = escapeSpoiler(res);
|
||||
if (heading2)
|
||||
res = escapeHeading(res);
|
||||
if (bulletedList)
|
||||
res = escapeBulletedList(res);
|
||||
if (numberedList)
|
||||
res = escapeNumberedList(res);
|
||||
if (maskedLink)
|
||||
res = escapeMaskedLink(res);
|
||||
return res;
|
||||
}
|
||||
__name(escapeMarkdown, "escapeMarkdown");
|
||||
function escapeCodeBlock(text) {
|
||||
return text.replaceAll("```", "\\`\\`\\`");
|
||||
}
|
||||
__name(escapeCodeBlock, "escapeCodeBlock");
|
||||
function escapeInlineCode(text) {
|
||||
return text.replaceAll(/(?<=^|[^`])``?(?=[^`]|$)/g, (match) => match.length === 2 ? "\\`\\`" : "\\`");
|
||||
}
|
||||
__name(escapeInlineCode, "escapeInlineCode");
|
||||
function escapeItalic(text) {
|
||||
let idx = 0;
|
||||
const newText = text.replaceAll(/(?<=^|[^*])\*([^*]|\*\*|$)/g, (_, match) => {
|
||||
if (match === "**")
|
||||
return ++idx % 2 ? `\\*${match}` : `${match}\\*`;
|
||||
return `\\*${match}`;
|
||||
});
|
||||
idx = 0;
|
||||
return newText.replaceAll(/(?<=^|[^_])(?<!<a?:.+)_(?!:\d+>)([^_]|__|$)/g, (_, match) => {
|
||||
if (match === "__")
|
||||
return ++idx % 2 ? `\\_${match}` : `${match}\\_`;
|
||||
return `\\_${match}`;
|
||||
});
|
||||
}
|
||||
__name(escapeItalic, "escapeItalic");
|
||||
function escapeBold(text) {
|
||||
let idx = 0;
|
||||
return text.replaceAll(/\*\*(\*)?/g, (_, match) => {
|
||||
if (match)
|
||||
return ++idx % 2 ? `${match}\\*\\*` : `\\*\\*${match}`;
|
||||
return "\\*\\*";
|
||||
});
|
||||
}
|
||||
__name(escapeBold, "escapeBold");
|
||||
function escapeUnderline(text) {
|
||||
let idx = 0;
|
||||
return text.replaceAll(/(?<!<a?:.+)__(_)?(?!:\d+>)/g, (_, match) => {
|
||||
if (match)
|
||||
return ++idx % 2 ? `${match}\\_\\_` : `\\_\\_${match}`;
|
||||
return "\\_\\_";
|
||||
});
|
||||
}
|
||||
__name(escapeUnderline, "escapeUnderline");
|
||||
function escapeStrikethrough(text) {
|
||||
return text.replaceAll("~~", "\\~\\~");
|
||||
}
|
||||
__name(escapeStrikethrough, "escapeStrikethrough");
|
||||
function escapeSpoiler(text) {
|
||||
return text.replaceAll("||", "\\|\\|");
|
||||
}
|
||||
__name(escapeSpoiler, "escapeSpoiler");
|
||||
function escapeEscape(text) {
|
||||
return text.replaceAll("\\", "\\\\");
|
||||
}
|
||||
__name(escapeEscape, "escapeEscape");
|
||||
function escapeHeading(text) {
|
||||
return text.replaceAll(/^( {0,2})([*-] )?( *)(#{1,3} )/gm, "$1$2$3\\$4");
|
||||
}
|
||||
__name(escapeHeading, "escapeHeading");
|
||||
function escapeBulletedList(text) {
|
||||
return text.replaceAll(/^( *)([*-])( +)/gm, "$1\\$2$3");
|
||||
}
|
||||
__name(escapeBulletedList, "escapeBulletedList");
|
||||
function escapeNumberedList(text) {
|
||||
return text.replaceAll(/^( *\d+)\./gm, "$1\\.");
|
||||
}
|
||||
__name(escapeNumberedList, "escapeNumberedList");
|
||||
function escapeMaskedLink(text) {
|
||||
return text.replaceAll(/\[.+]\(.+\)/gm, "\\$&");
|
||||
}
|
||||
__name(escapeMaskedLink, "escapeMaskedLink");
|
||||
|
||||
// src/formatters.ts
|
||||
function codeBlock(language, content) {
|
||||
return content === void 0 ? `\`\`\`
|
||||
${language}
|
||||
\`\`\`` : `\`\`\`${language}
|
||||
${content}
|
||||
\`\`\``;
|
||||
}
|
||||
__name(codeBlock, "codeBlock");
|
||||
function inlineCode(content) {
|
||||
return `\`${content}\``;
|
||||
}
|
||||
__name(inlineCode, "inlineCode");
|
||||
function italic(content) {
|
||||
return `_${content}_`;
|
||||
}
|
||||
__name(italic, "italic");
|
||||
function bold(content) {
|
||||
return `**${content}**`;
|
||||
}
|
||||
__name(bold, "bold");
|
||||
function underscore(content) {
|
||||
return `__${content}__`;
|
||||
}
|
||||
__name(underscore, "underscore");
|
||||
function strikethrough(content) {
|
||||
return `~~${content}~~`;
|
||||
}
|
||||
__name(strikethrough, "strikethrough");
|
||||
function quote(content) {
|
||||
return `> ${content}`;
|
||||
}
|
||||
__name(quote, "quote");
|
||||
function blockQuote(content) {
|
||||
return `>>> ${content}`;
|
||||
}
|
||||
__name(blockQuote, "blockQuote");
|
||||
function hideLinkEmbed(url) {
|
||||
return `<${url}>`;
|
||||
}
|
||||
__name(hideLinkEmbed, "hideLinkEmbed");
|
||||
function hyperlink(content, url, title) {
|
||||
return title ? `[${content}](${url} "${title}")` : `[${content}](${url})`;
|
||||
}
|
||||
__name(hyperlink, "hyperlink");
|
||||
function spoiler(content) {
|
||||
return `||${content}||`;
|
||||
}
|
||||
__name(spoiler, "spoiler");
|
||||
function userMention(userId) {
|
||||
return `<@${userId}>`;
|
||||
}
|
||||
__name(userMention, "userMention");
|
||||
function channelMention(channelId) {
|
||||
return `<#${channelId}>`;
|
||||
}
|
||||
__name(channelMention, "channelMention");
|
||||
function roleMention(roleId) {
|
||||
return `<@&${roleId}>`;
|
||||
}
|
||||
__name(roleMention, "roleMention");
|
||||
function chatInputApplicationCommandMention(commandName, subcommandGroupName, subcommandName, commandId) {
|
||||
if (commandId !== void 0) {
|
||||
return `</${commandName} ${subcommandGroupName} ${subcommandName}:${commandId}>`;
|
||||
}
|
||||
if (subcommandName !== void 0) {
|
||||
return `</${commandName} ${subcommandGroupName}:${subcommandName}>`;
|
||||
}
|
||||
return `</${commandName}:${subcommandGroupName}>`;
|
||||
}
|
||||
__name(chatInputApplicationCommandMention, "chatInputApplicationCommandMention");
|
||||
function formatEmoji(emojiId, animated = false) {
|
||||
return `<${animated ? "a" : ""}:_:${emojiId}>`;
|
||||
}
|
||||
__name(formatEmoji, "formatEmoji");
|
||||
function channelLink(channelId, guildId) {
|
||||
return `https://discord.com/channels/${guildId ?? "@me"}/${channelId}`;
|
||||
}
|
||||
__name(channelLink, "channelLink");
|
||||
function messageLink(channelId, messageId, guildId) {
|
||||
return `${guildId === void 0 ? channelLink(channelId) : channelLink(channelId, guildId)}/${messageId}`;
|
||||
}
|
||||
__name(messageLink, "messageLink");
|
||||
var HeadingLevel = /* @__PURE__ */ ((HeadingLevel2) => {
|
||||
HeadingLevel2[HeadingLevel2["One"] = 1] = "One";
|
||||
HeadingLevel2[HeadingLevel2["Two"] = 2] = "Two";
|
||||
HeadingLevel2[HeadingLevel2["Three"] = 3] = "Three";
|
||||
return HeadingLevel2;
|
||||
})(HeadingLevel || {});
|
||||
function heading(content, level) {
|
||||
switch (level) {
|
||||
case 3 /* Three */:
|
||||
return `### ${content}`;
|
||||
case 2 /* Two */:
|
||||
return `## ${content}`;
|
||||
default:
|
||||
return `# ${content}`;
|
||||
}
|
||||
}
|
||||
__name(heading, "heading");
|
||||
function listCallback(element, startNumber, depth = 0) {
|
||||
if (Array.isArray(element)) {
|
||||
return element.map((element2) => listCallback(element2, startNumber, depth + 1)).join("\n");
|
||||
}
|
||||
return `${" ".repeat(depth - 1)}${startNumber ? `${startNumber}.` : "-"} ${element}`;
|
||||
}
|
||||
__name(listCallback, "listCallback");
|
||||
function orderedList(list, startNumber = 1) {
|
||||
return listCallback(list, Math.max(startNumber, 1));
|
||||
}
|
||||
__name(orderedList, "orderedList");
|
||||
function unorderedList(list) {
|
||||
return listCallback(list);
|
||||
}
|
||||
__name(unorderedList, "unorderedList");
|
||||
function time(timeOrSeconds, style) {
|
||||
if (typeof timeOrSeconds !== "number") {
|
||||
timeOrSeconds = Math.floor((timeOrSeconds?.getTime() ?? Date.now()) / 1e3);
|
||||
}
|
||||
return typeof style === "string" ? `<t:${timeOrSeconds}:${style}>` : `<t:${timeOrSeconds}>`;
|
||||
}
|
||||
__name(time, "time");
|
||||
var TimestampStyles = {
|
||||
/**
|
||||
* Short time format, consisting of hours and minutes.
|
||||
*
|
||||
* @example `16:20`
|
||||
*/
|
||||
ShortTime: "t",
|
||||
/**
|
||||
* Long time format, consisting of hours, minutes, and seconds.
|
||||
*
|
||||
* @example `16:20:30`
|
||||
*/
|
||||
LongTime: "T",
|
||||
/**
|
||||
* Short date format, consisting of day, month, and year.
|
||||
*
|
||||
* @example `20/04/2021`
|
||||
*/
|
||||
ShortDate: "d",
|
||||
/**
|
||||
* Long date format, consisting of day, month, and year.
|
||||
*
|
||||
* @example `20 April 2021`
|
||||
*/
|
||||
LongDate: "D",
|
||||
/**
|
||||
* Short date-time format, consisting of short date and short time formats.
|
||||
*
|
||||
* @example `20 April 2021 16:20`
|
||||
*/
|
||||
ShortDateTime: "f",
|
||||
/**
|
||||
* Long date-time format, consisting of long date and short time formats.
|
||||
*
|
||||
* @example `Tuesday, 20 April 2021 16:20`
|
||||
*/
|
||||
LongDateTime: "F",
|
||||
/**
|
||||
* Relative time format, consisting of a relative duration format.
|
||||
*
|
||||
* @example `2 months ago`
|
||||
*/
|
||||
RelativeTime: "R"
|
||||
};
|
||||
var Faces = /* @__PURE__ */ ((Faces2) => {
|
||||
Faces2["Shrug"] = "\xAF_(\u30C4)_/\xAF";
|
||||
Faces2["Tableflip"] = "(\u256F\xB0\u25A1\xB0)\u256F\uFE35 \u253B\u2501\u253B";
|
||||
Faces2["Unflip"] = "\u252C\u2500\u252C\u30CE( \xBA _ \xBA\u30CE)";
|
||||
return Faces2;
|
||||
})(Faces || {});
|
||||
var GuildNavigationMentions = /* @__PURE__ */ ((GuildNavigationMentions2) => {
|
||||
GuildNavigationMentions2["Browse"] = "<id:browse>";
|
||||
GuildNavigationMentions2["Customize"] = "<id:customize>";
|
||||
GuildNavigationMentions2["Guide"] = "<id:guide>";
|
||||
return GuildNavigationMentions2;
|
||||
})(GuildNavigationMentions || {});
|
||||
export {
|
||||
Faces,
|
||||
GuildNavigationMentions,
|
||||
HeadingLevel,
|
||||
TimestampStyles,
|
||||
blockQuote,
|
||||
bold,
|
||||
channelLink,
|
||||
channelMention,
|
||||
chatInputApplicationCommandMention,
|
||||
codeBlock,
|
||||
escapeBold,
|
||||
escapeBulletedList,
|
||||
escapeCodeBlock,
|
||||
escapeEscape,
|
||||
escapeHeading,
|
||||
escapeInlineCode,
|
||||
escapeItalic,
|
||||
escapeMarkdown,
|
||||
escapeMaskedLink,
|
||||
escapeNumberedList,
|
||||
escapeSpoiler,
|
||||
escapeStrikethrough,
|
||||
escapeUnderline,
|
||||
formatEmoji,
|
||||
heading,
|
||||
hideLinkEmbed,
|
||||
hyperlink,
|
||||
inlineCode,
|
||||
italic,
|
||||
messageLink,
|
||||
orderedList,
|
||||
quote,
|
||||
roleMention,
|
||||
spoiler,
|
||||
strikethrough,
|
||||
time,
|
||||
underscore,
|
||||
unorderedList,
|
||||
userMention
|
||||
};
|
||||
//# sourceMappingURL=index.mjs.map
|
1
node_modules/@discordjs/formatters/dist/index.mjs.map
generated
vendored
Normal file
1
node_modules/@discordjs/formatters/dist/index.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
79
node_modules/@discordjs/formatters/package.json
generated
vendored
Normal file
79
node_modules/@discordjs/formatters/package.json
generated
vendored
Normal file
|
@ -0,0 +1,79 @@
|
|||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "@discordjs/formatters",
|
||||
"version": "0.3.3",
|
||||
"description": "A set of functions to format strings for Discord.",
|
||||
"exports": {
|
||||
".": {
|
||||
"require": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"import": {
|
||||
"types": "./dist/index.d.mts",
|
||||
"default": "./dist/index.mjs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
"directories": {
|
||||
"lib": "src",
|
||||
"test": "__tests__"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"contributors": [
|
||||
"Crawl <icrawltogo@gmail.com>",
|
||||
"SpaceEEC <spaceeec@yahoo.com>",
|
||||
"Vlad Frangu <kingdgrizzle@gmail.com>",
|
||||
"Aura Román <kyradiscord@gmail.com>"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"keywords": [],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/discordjs/discord.js.git",
|
||||
"directory": "packages/formatters"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/discordjs/discord.js/issues"
|
||||
},
|
||||
"homepage": "https://discord.js.org",
|
||||
"dependencies": {
|
||||
"discord-api-types": "0.37.61"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@favware/cliff-jumper": "^2.2.1",
|
||||
"@types/node": "16.18.60",
|
||||
"@vitest/coverage-v8": "^0.34.6",
|
||||
"cross-env": "^7.0.3",
|
||||
"eslint": "^8.53.0",
|
||||
"eslint-config-neon": "^0.1.57",
|
||||
"eslint-formatter-pretty": "^5.0.0",
|
||||
"prettier": "^3.0.3",
|
||||
"tsup": "^7.2.0",
|
||||
"turbo": "^1.10.17-canary.0",
|
||||
"typescript": "^5.2.2",
|
||||
"vitest": "^0.34.6",
|
||||
"@discordjs/api-extractor": "^7.38.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.11.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "vitest run",
|
||||
"build": "tsc --noEmit && tsup",
|
||||
"build:docs": "tsc -p tsconfig.docs.json",
|
||||
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
|
||||
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
|
||||
"docs": "pnpm run build:docs && api-extractor run --local",
|
||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/formatters/*'",
|
||||
"release": "cliff-jumper"
|
||||
}
|
||||
}
|
192
node_modules/@discordjs/rest/LICENSE
generated
vendored
Normal file
192
node_modules/@discordjs/rest/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,192 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Copyright 2021 Noel Buechler
|
||||
Copyright 2021 Vlad Frangu
|
||||
Copyright 2021 Aura Román
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
139
node_modules/@discordjs/rest/README.md
generated
vendored
Normal file
139
node_modules/@discordjs/rest/README.md
generated
vendored
Normal file
|
@ -0,0 +1,139 @@
|
|||
<div align="center">
|
||||
<br />
|
||||
<p>
|
||||
<a href="https://discord.js.org"><img src="https://discord.js.org/static/logo.svg" width="546" alt="discord.js" /></a>
|
||||
</p>
|
||||
<br />
|
||||
<p>
|
||||
<a href="https://discord.gg/djs"><img src="https://img.shields.io/discord/222078108977594368?color=5865F2&logo=discord&logoColor=white" alt="Discord server" /></a>
|
||||
<a href="https://www.npmjs.com/package/@discordjs/rest"><img src="https://img.shields.io/npm/v/@discordjs/rest.svg?maxAge=3600" alt="npm version" /></a>
|
||||
<a href="https://www.npmjs.com/package/@discordjs/rest"><img src="https://img.shields.io/npm/dt/@discordjs/rest.svg?maxAge=3600" alt="npm downloads" /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Tests status" /></a>
|
||||
<a href="https://codecov.io/gh/discordjs/discord.js" ><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2&flag=rest" alt="Code coverage" /></a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
|
||||
<a href="https://www.cloudflare.com"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-workers.png" alt="Cloudflare Workers" height="44" /></a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
## About
|
||||
|
||||
`@discordjs/rest` is a module that allows you to easily make REST requests to the Discord API.
|
||||
|
||||
## Installation
|
||||
|
||||
**Node.js 16.11.0 or newer is required.**
|
||||
|
||||
Note: native fetch (not recommended) is unavailable in this node version, either use a newer node version or use the more performant `undiciRequest` strategy (default)
|
||||
|
||||
```sh
|
||||
npm install @discordjs/rest
|
||||
yarn add @discordjs/rest
|
||||
pnpm add @discordjs/rest
|
||||
bun add @discordjs/rest
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
Install all required dependencies:
|
||||
|
||||
```sh
|
||||
npm install @discordjs/rest discord-api-types
|
||||
yarn add @discordjs/rest discord-api-types
|
||||
pnpm add @discordjs/rest discord-api-types
|
||||
bun add @discordjs/rest discord-api-types
|
||||
```
|
||||
|
||||
Send a basic message:
|
||||
|
||||
```js
|
||||
import { REST } from '@discordjs/rest';
|
||||
import { Routes } from 'discord-api-types/v10';
|
||||
|
||||
const rest = new REST({ version: '10' }).setToken(TOKEN);
|
||||
|
||||
try {
|
||||
await rest.post(Routes.channelMessages(CHANNEL_ID), {
|
||||
body: {
|
||||
content: 'A message via REST!',
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
```
|
||||
|
||||
Create a thread from an existing message to be archived after 60 minutes of inactivity:
|
||||
|
||||
```js
|
||||
import { REST } from '@discordjs/rest';
|
||||
import { Routes } from 'discord-api-types/v10';
|
||||
|
||||
const rest = new REST({ version: '10' }).setToken(TOKEN);
|
||||
|
||||
try {
|
||||
await rest.post(Routes.threads(CHANNEL_ID, MESSAGE_ID), {
|
||||
body: {
|
||||
name: 'Thread',
|
||||
auto_archive_duration: 60,
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
```
|
||||
|
||||
Send a basic message in an edge environment:
|
||||
|
||||
```js
|
||||
import { REST } from '@discordjs/rest';
|
||||
import { Routes } from 'discord-api-types/v10';
|
||||
|
||||
const rest = new REST({ version: '10', makeRequest: fetch }).setToken(TOKEN);
|
||||
|
||||
try {
|
||||
await rest.post(Routes.channelMessages(CHANNEL_ID), {
|
||||
body: {
|
||||
content: 'A message via REST from the edge!',
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
```
|
||||
|
||||
## Links
|
||||
|
||||
- [Website][website] ([source][website-source])
|
||||
- [Documentation][documentation]
|
||||
- [Guide][guide] ([source][guide-source])
|
||||
Also see the v13 to v14 [Update Guide][guide-update], which includes updated and removed items from the library.
|
||||
- [discord.js Discord server][discord]
|
||||
- [Discord API Discord server][discord-api]
|
||||
- [GitHub][source]
|
||||
- [npm][npm]
|
||||
- [Related libraries][related-libs]
|
||||
|
||||
## Contributing
|
||||
|
||||
Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the
|
||||
[documentation][documentation].
|
||||
See [the contribution guide][contributing] if you'd like to submit a PR.
|
||||
|
||||
## Help
|
||||
|
||||
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to join our official [discord.js Server][discord].
|
||||
|
||||
[website]: https://discord.js.org
|
||||
[website-source]: https://github.com/discordjs/discord.js/tree/main/apps/website
|
||||
[documentation]: https://discord.js.org/docs/packages/rest/stable
|
||||
[guide]: https://discordjs.guide/
|
||||
[guide-source]: https://github.com/discordjs/guide
|
||||
[guide-update]: https://discordjs.guide/additional-info/changes-in-v14.html
|
||||
[discord]: https://discord.gg/djs
|
||||
[discord-api]: https://discord.gg/discord-api
|
||||
[source]: https://github.com/discordjs/discord.js/tree/main/packages/rest
|
||||
[npm]: https://www.npmjs.com/package/@discordjs/rest
|
||||
[related-libs]: https://discord.com/developers/docs/topics/community-resources#libraries
|
||||
[contributing]: https://github.com/discordjs/discord.js/blob/main/.github/CONTRIBUTING.md
|
901
node_modules/@discordjs/rest/dist/index.d.mts
generated
vendored
Normal file
901
node_modules/@discordjs/rest/dist/index.d.mts
generated
vendored
Normal file
|
@ -0,0 +1,901 @@
|
|||
import * as url from 'url';
|
||||
import { Snowflake } from 'discord-api-types/v10';
|
||||
import { Readable } from 'node:stream';
|
||||
import { ReadableStream } from 'node:stream/web';
|
||||
import { Collection } from '@discordjs/collection';
|
||||
import { Awaitable } from '@discordjs/util';
|
||||
import * as undici from 'undici';
|
||||
import { RequestInit, Dispatcher, Response, BodyInit, Agent } from 'undici';
|
||||
import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
|
||||
|
||||
interface IHandler {
|
||||
/**
|
||||
* The unique id of the handler
|
||||
*/
|
||||
readonly id: string;
|
||||
/**
|
||||
* If the bucket is currently inactive (no pending requests)
|
||||
*/
|
||||
get inactive(): boolean;
|
||||
/**
|
||||
* Queues a request to be sent
|
||||
*
|
||||
* @param routeId - The generalized api route with literal ids for major parameters
|
||||
* @param url - The url to do the request on
|
||||
* @param options - All the information needed to make a request
|
||||
* @param requestData - Extra data from the user's request needed for errors and additional processing
|
||||
*/
|
||||
queueRequest(routeId: RouteData, url: string, options: RequestInit, requestData: HandlerRequestData): Promise<ResponseLike>;
|
||||
}
|
||||
|
||||
interface RestEvents {
|
||||
handlerSweep: [sweptHandlers: Collection<string, IHandler>];
|
||||
hashSweep: [sweptHashes: Collection<string, HashData>];
|
||||
invalidRequestWarning: [invalidRequestInfo: InvalidRequestWarningData];
|
||||
rateLimited: [rateLimitInfo: RateLimitData];
|
||||
response: [request: APIRequest, response: ResponseLike];
|
||||
restDebug: [info: string];
|
||||
}
|
||||
type RestEventsMap = {
|
||||
[K in keyof RestEvents]: RestEvents[K];
|
||||
};
|
||||
/**
|
||||
* Options to be passed when creating the REST instance
|
||||
*/
|
||||
interface RESTOptions {
|
||||
/**
|
||||
* The agent to set globally
|
||||
*/
|
||||
agent: Dispatcher | null;
|
||||
/**
|
||||
* The base api path, without version
|
||||
*
|
||||
* @defaultValue `'https://discord.com/api'`
|
||||
*/
|
||||
api: string;
|
||||
/**
|
||||
* The authorization prefix to use for requests, useful if you want to use
|
||||
* bearer tokens
|
||||
*
|
||||
* @defaultValue `'Bot'`
|
||||
*/
|
||||
authPrefix: 'Bearer' | 'Bot';
|
||||
/**
|
||||
* The cdn path
|
||||
*
|
||||
* @defaultValue `'https://cdn.discordapp.com'`
|
||||
*/
|
||||
cdn: string;
|
||||
/**
|
||||
* How many requests to allow sending per second (Infinity for unlimited, 50 for the standard global limit used by Discord)
|
||||
*
|
||||
* @defaultValue `50`
|
||||
*/
|
||||
globalRequestsPerSecond: number;
|
||||
/**
|
||||
* The amount of time in milliseconds that passes between each hash sweep. (defaults to 1h)
|
||||
*
|
||||
* @defaultValue `3_600_000`
|
||||
*/
|
||||
handlerSweepInterval: number;
|
||||
/**
|
||||
* The maximum amount of time a hash can exist in milliseconds without being hit with a request (defaults to 24h)
|
||||
*
|
||||
* @defaultValue `86_400_000`
|
||||
*/
|
||||
hashLifetime: number;
|
||||
/**
|
||||
* The amount of time in milliseconds that passes between each hash sweep. (defaults to 4h)
|
||||
*
|
||||
* @defaultValue `14_400_000`
|
||||
*/
|
||||
hashSweepInterval: number;
|
||||
/**
|
||||
* Additional headers to send for all API requests
|
||||
*
|
||||
* @defaultValue `{}`
|
||||
*/
|
||||
headers: Record<string, string>;
|
||||
/**
|
||||
* The number of invalid REST requests (those that return 401, 403, or 429) in a 10 minute window between emitted warnings (0 for no warnings).
|
||||
* That is, if set to 500, warnings will be emitted at invalid request number 500, 1000, 1500, and so on.
|
||||
*
|
||||
* @defaultValue `0`
|
||||
*/
|
||||
invalidRequestWarningInterval: number;
|
||||
/**
|
||||
* The method called to perform the actual HTTP request given a url and web `fetch` options
|
||||
* For example, to use global fetch, simply provide `makeRequest: fetch`
|
||||
*/
|
||||
makeRequest(url: string, init: RequestInit): Promise<ResponseLike>;
|
||||
/**
|
||||
* The extra offset to add to rate limits in milliseconds
|
||||
*
|
||||
* @defaultValue `50`
|
||||
*/
|
||||
offset: number;
|
||||
/**
|
||||
* Determines how rate limiting and pre-emptive throttling should be handled.
|
||||
* When an array of strings, each element is treated as a prefix for the request route
|
||||
* (e.g. `/channels` to match any route starting with `/channels` such as `/channels/:id/messages`)
|
||||
* for which to throw {@link RateLimitError}s. All other request routes will be queued normally
|
||||
*
|
||||
* @defaultValue `null`
|
||||
*/
|
||||
rejectOnRateLimit: RateLimitQueueFilter | string[] | null;
|
||||
/**
|
||||
* The number of retries for errors with the 500 code, or errors
|
||||
* that timeout
|
||||
*
|
||||
* @defaultValue `3`
|
||||
*/
|
||||
retries: number;
|
||||
/**
|
||||
* The time to wait in milliseconds before a request is aborted
|
||||
*
|
||||
* @defaultValue `15_000`
|
||||
*/
|
||||
timeout: number;
|
||||
/**
|
||||
* Extra information to add to the user agent
|
||||
*
|
||||
* @defaultValue DefaultUserAgentAppendix
|
||||
*/
|
||||
userAgentAppendix: string;
|
||||
/**
|
||||
* The version of the API to use
|
||||
*
|
||||
* @defaultValue `'10'`
|
||||
*/
|
||||
version: string;
|
||||
}
|
||||
/**
|
||||
* Data emitted on `RESTEvents.RateLimited`
|
||||
*/
|
||||
interface RateLimitData {
|
||||
/**
|
||||
* Whether the rate limit that was reached was the global limit
|
||||
*/
|
||||
global: boolean;
|
||||
/**
|
||||
* The bucket hash for this request
|
||||
*/
|
||||
hash: string;
|
||||
/**
|
||||
* The amount of requests we can perform before locking requests
|
||||
*/
|
||||
limit: number;
|
||||
/**
|
||||
* The major parameter of the route
|
||||
*
|
||||
* For example, in `/channels/x`, this will be `x`.
|
||||
* If there is no major parameter (e.g: `/bot/gateway`) this will be `global`.
|
||||
*/
|
||||
majorParameter: string;
|
||||
/**
|
||||
* The HTTP method being performed
|
||||
*/
|
||||
method: string;
|
||||
/**
|
||||
* The time, in milliseconds, that will need to pass before this specific request can be retried
|
||||
*/
|
||||
retryAfter: number;
|
||||
/**
|
||||
* The route being hit in this request
|
||||
*/
|
||||
route: string;
|
||||
/**
|
||||
* The scope of the rate limit that was hit.
|
||||
*
|
||||
* This can be `user` for rate limits that are per client, `global` for rate limits that affect all clients or `shared` for rate limits that
|
||||
* are shared per resource.
|
||||
*/
|
||||
scope: 'global' | 'shared' | 'user';
|
||||
/**
|
||||
* The time, in milliseconds, that will need to pass before the sublimit lock for the route resets, and requests that fall under a sublimit
|
||||
* can be retried
|
||||
*
|
||||
* This is only present on certain sublimits, and `0` otherwise
|
||||
*/
|
||||
sublimitTimeout: number;
|
||||
/**
|
||||
* The time, in milliseconds, until the route's request-lock is reset
|
||||
*/
|
||||
timeToReset: number;
|
||||
/**
|
||||
* The full URL for this request
|
||||
*/
|
||||
url: string;
|
||||
}
|
||||
/**
|
||||
* A function that determines whether the rate limit hit should throw an Error
|
||||
*/
|
||||
type RateLimitQueueFilter = (rateLimitData: RateLimitData) => Awaitable<boolean>;
|
||||
interface APIRequest {
|
||||
/**
|
||||
* The data that was used to form the body of this request
|
||||
*/
|
||||
data: HandlerRequestData;
|
||||
/**
|
||||
* The HTTP method used in this request
|
||||
*/
|
||||
method: string;
|
||||
/**
|
||||
* Additional HTTP options for this request
|
||||
*/
|
||||
options: RequestInit;
|
||||
/**
|
||||
* The full path used to make the request
|
||||
*/
|
||||
path: RouteLike;
|
||||
/**
|
||||
* The number of times this request has been attempted
|
||||
*/
|
||||
retries: number;
|
||||
/**
|
||||
* The API route identifying the ratelimit for this request
|
||||
*/
|
||||
route: string;
|
||||
}
|
||||
interface ResponseLike extends Pick<Response, 'arrayBuffer' | 'bodyUsed' | 'headers' | 'json' | 'ok' | 'status' | 'statusText' | 'text'> {
|
||||
body: Readable | ReadableStream | null;
|
||||
}
|
||||
interface InvalidRequestWarningData {
|
||||
/**
|
||||
* Number of invalid requests that have been made in the window
|
||||
*/
|
||||
count: number;
|
||||
/**
|
||||
* Time in milliseconds remaining before the count resets
|
||||
*/
|
||||
remainingTime: number;
|
||||
}
|
||||
/**
|
||||
* Represents a file to be added to the request
|
||||
*/
|
||||
interface RawFile {
|
||||
/**
|
||||
* Content-Type of the file
|
||||
*/
|
||||
contentType?: string;
|
||||
/**
|
||||
* The actual data for the file
|
||||
*/
|
||||
data: Buffer | Uint8Array | boolean | number | string;
|
||||
/**
|
||||
* An explicit key to use for key of the formdata field for this file.
|
||||
* When not provided, the index of the file in the files array is used in the form `files[${index}]`.
|
||||
* If you wish to alter the placeholder snowflake, you must provide this property in the same form (`files[${placeholder}]`)
|
||||
*/
|
||||
key?: string;
|
||||
/**
|
||||
* The name of the file
|
||||
*/
|
||||
name: string;
|
||||
}
|
||||
/**
|
||||
* Represents possible data to be given to an endpoint
|
||||
*/
|
||||
interface RequestData {
|
||||
/**
|
||||
* Whether to append JSON data to form data instead of `payload_json` when sending files
|
||||
*/
|
||||
appendToFormData?: boolean;
|
||||
/**
|
||||
* If this request needs the `Authorization` header
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
auth?: boolean;
|
||||
/**
|
||||
* The authorization prefix to use for this request, useful if you use this with bearer tokens
|
||||
*
|
||||
* @defaultValue `'Bot'`
|
||||
*/
|
||||
authPrefix?: 'Bearer' | 'Bot';
|
||||
/**
|
||||
* The body to send to this request.
|
||||
* If providing as BodyInit, set `passThroughBody: true`
|
||||
*/
|
||||
body?: BodyInit | unknown;
|
||||
/**
|
||||
* The {@link https://undici.nodejs.org/#/docs/api/Agent | Agent} to use for the request.
|
||||
*/
|
||||
dispatcher?: Agent;
|
||||
/**
|
||||
* Files to be attached to this request
|
||||
*/
|
||||
files?: RawFile[] | undefined;
|
||||
/**
|
||||
* Additional headers to add to this request
|
||||
*/
|
||||
headers?: Record<string, string>;
|
||||
/**
|
||||
* Whether to pass-through the body property directly to `fetch()`.
|
||||
* <warn>This only applies when files is NOT present</warn>
|
||||
*/
|
||||
passThroughBody?: boolean;
|
||||
/**
|
||||
* Query string parameters to append to the called endpoint
|
||||
*/
|
||||
query?: URLSearchParams;
|
||||
/**
|
||||
* Reason to show in the audit logs
|
||||
*/
|
||||
reason?: string | undefined;
|
||||
/**
|
||||
* The signal to abort the queue entry or the REST call, where applicable
|
||||
*/
|
||||
signal?: AbortSignal | undefined;
|
||||
/**
|
||||
* If this request should be versioned
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
versioned?: boolean;
|
||||
}
|
||||
/**
|
||||
* Possible headers for an API call
|
||||
*/
|
||||
interface RequestHeaders {
|
||||
Authorization?: string;
|
||||
'User-Agent': string;
|
||||
'X-Audit-Log-Reason'?: string;
|
||||
}
|
||||
/**
|
||||
* Possible API methods to be used when doing requests
|
||||
*/
|
||||
declare enum RequestMethod {
|
||||
Delete = "DELETE",
|
||||
Get = "GET",
|
||||
Patch = "PATCH",
|
||||
Post = "POST",
|
||||
Put = "PUT"
|
||||
}
|
||||
type RouteLike = `/${string}`;
|
||||
/**
|
||||
* Internal request options
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface InternalRequest extends RequestData {
|
||||
fullRoute: RouteLike;
|
||||
method: RequestMethod;
|
||||
}
|
||||
type HandlerRequestData = Pick<InternalRequest, 'auth' | 'body' | 'files' | 'signal'>;
|
||||
/**
|
||||
* Parsed route data for an endpoint
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface RouteData {
|
||||
bucketRoute: string;
|
||||
majorParameter: string;
|
||||
original: RouteLike;
|
||||
}
|
||||
/**
|
||||
* Represents a hash and its associated fields
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface HashData {
|
||||
lastAccess: number;
|
||||
value: string;
|
||||
}
|
||||
|
||||
declare const DefaultUserAgent: `DiscordBot (https://discord.js.org, ${string})`;
|
||||
/**
|
||||
* The default string to append onto the user agent.
|
||||
*/
|
||||
declare const DefaultUserAgentAppendix: string;
|
||||
declare const DefaultRestOptions: {
|
||||
readonly agent: null;
|
||||
readonly api: "https://discord.com/api";
|
||||
readonly authPrefix: "Bot";
|
||||
readonly cdn: "https://cdn.discordapp.com";
|
||||
readonly headers: {};
|
||||
readonly invalidRequestWarningInterval: 0;
|
||||
readonly globalRequestsPerSecond: 50;
|
||||
readonly offset: 50;
|
||||
readonly rejectOnRateLimit: null;
|
||||
readonly retries: 3;
|
||||
readonly timeout: 15000;
|
||||
readonly userAgentAppendix: string;
|
||||
readonly version: "10";
|
||||
readonly hashSweepInterval: 14400000;
|
||||
readonly hashLifetime: 86400000;
|
||||
readonly handlerSweepInterval: 3600000;
|
||||
readonly makeRequest: (url: string, init: undici.RequestInit) => Promise<ResponseLike>;
|
||||
};
|
||||
/**
|
||||
* The events that the REST manager emits
|
||||
*/
|
||||
declare enum RESTEvents {
|
||||
Debug = "restDebug",
|
||||
HandlerSweep = "handlerSweep",
|
||||
HashSweep = "hashSweep",
|
||||
InvalidRequestWarning = "invalidRequestWarning",
|
||||
RateLimited = "rateLimited",
|
||||
Response = "response"
|
||||
}
|
||||
declare const ALLOWED_EXTENSIONS: readonly ["webp", "png", "jpg", "jpeg", "gif"];
|
||||
declare const ALLOWED_STICKER_EXTENSIONS: readonly ["png", "json", "gif"];
|
||||
declare const ALLOWED_SIZES: readonly [16, 32, 64, 128, 256, 512, 1024, 2048, 4096];
|
||||
type ImageExtension = (typeof ALLOWED_EXTENSIONS)[number];
|
||||
type StickerExtension = (typeof ALLOWED_STICKER_EXTENSIONS)[number];
|
||||
type ImageSize = (typeof ALLOWED_SIZES)[number];
|
||||
declare const OverwrittenMimeTypes: {
|
||||
readonly 'image/apng': "image/png";
|
||||
};
|
||||
declare const BurstHandlerMajorIdKey = "burst";
|
||||
/**
|
||||
* Prefix for deprecation warnings.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
declare const DEPRECATION_WARNING_PREFIX: "DeprecationWarning";
|
||||
|
||||
/**
|
||||
* The options used for image URLs
|
||||
*/
|
||||
interface BaseImageURLOptions {
|
||||
/**
|
||||
* The extension to use for the image URL
|
||||
*
|
||||
* @defaultValue `'webp'`
|
||||
*/
|
||||
extension?: ImageExtension;
|
||||
/**
|
||||
* The size specified in the image URL
|
||||
*/
|
||||
size?: ImageSize;
|
||||
}
|
||||
/**
|
||||
* The options used for image URLs with animated content
|
||||
*/
|
||||
interface ImageURLOptions extends BaseImageURLOptions {
|
||||
/**
|
||||
* Whether or not to prefer the static version of an image asset.
|
||||
*/
|
||||
forceStatic?: boolean;
|
||||
}
|
||||
/**
|
||||
* The options to use when making a CDN URL
|
||||
*/
|
||||
interface MakeURLOptions {
|
||||
/**
|
||||
* The allowed extensions that can be used
|
||||
*/
|
||||
allowedExtensions?: readonly string[];
|
||||
/**
|
||||
* The extension to use for the image URL
|
||||
*
|
||||
* @defaultValue `'webp'`
|
||||
*/
|
||||
extension?: string | undefined;
|
||||
/**
|
||||
* The size specified in the image URL
|
||||
*/
|
||||
size?: ImageSize;
|
||||
}
|
||||
/**
|
||||
* The CDN link builder
|
||||
*/
|
||||
declare class CDN {
|
||||
private readonly base;
|
||||
constructor(base?: string);
|
||||
/**
|
||||
* Generates an app asset URL for a client's asset.
|
||||
*
|
||||
* @param clientId - The client id that has the asset
|
||||
* @param assetHash - The hash provided by Discord for this asset
|
||||
* @param options - Optional options for the asset
|
||||
*/
|
||||
appAsset(clientId: string, assetHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates an app icon URL for a client's icon.
|
||||
*
|
||||
* @param clientId - The client id that has the icon
|
||||
* @param iconHash - The hash provided by Discord for this icon
|
||||
* @param options - Optional options for the icon
|
||||
*/
|
||||
appIcon(clientId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates an avatar URL, e.g. for a user or a webhook.
|
||||
*
|
||||
* @param id - The id that has the icon
|
||||
* @param avatarHash - The hash provided by Discord for this avatar
|
||||
* @param options - Optional options for the avatar
|
||||
*/
|
||||
avatar(id: string, avatarHash: string, options?: Readonly<ImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a user avatar decoration URL.
|
||||
*
|
||||
* @param userId - The id of the user
|
||||
* @param userAvatarDecoration - The hash provided by Discord for this avatar decoration
|
||||
* @param options - Optional options for the avatar decoration
|
||||
*/
|
||||
avatarDecoration(userId: string, userAvatarDecoration: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a banner URL, e.g. for a user or a guild.
|
||||
*
|
||||
* @param id - The id that has the banner splash
|
||||
* @param bannerHash - The hash provided by Discord for this banner
|
||||
* @param options - Optional options for the banner
|
||||
*/
|
||||
banner(id: string, bannerHash: string, options?: Readonly<ImageURLOptions>): string;
|
||||
/**
|
||||
* Generates an icon URL for a channel, e.g. a group DM.
|
||||
*
|
||||
* @param channelId - The channel id that has the icon
|
||||
* @param iconHash - The hash provided by Discord for this channel
|
||||
* @param options - Optional options for the icon
|
||||
*/
|
||||
channelIcon(channelId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a default avatar URL
|
||||
*
|
||||
* @param index - The default avatar index
|
||||
* @remarks
|
||||
* To calculate the index for a user do `(userId >> 22) % 6`,
|
||||
* or `discriminator % 5` if they're using the legacy username system.
|
||||
*/
|
||||
defaultAvatar(index: number): string;
|
||||
/**
|
||||
* Generates a discovery splash URL for a guild's discovery splash.
|
||||
*
|
||||
* @param guildId - The guild id that has the discovery splash
|
||||
* @param splashHash - The hash provided by Discord for this splash
|
||||
* @param options - Optional options for the splash
|
||||
*/
|
||||
discoverySplash(guildId: string, splashHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates an emoji's URL for an emoji.
|
||||
*
|
||||
* @param emojiId - The emoji id
|
||||
* @param options - Optional options for the emoji
|
||||
*/
|
||||
emoji(emojiId: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates an emoji's URL for an emoji.
|
||||
*
|
||||
* @param emojiId - The emoji id
|
||||
* @param extension - The extension of the emoji
|
||||
* @deprecated This overload is deprecated. Pass an object containing the extension instead.
|
||||
*/
|
||||
emoji(emojiId: string, extension?: ImageExtension): string;
|
||||
/**
|
||||
* Generates a guild member avatar URL.
|
||||
*
|
||||
* @param guildId - The id of the guild
|
||||
* @param userId - The id of the user
|
||||
* @param avatarHash - The hash provided by Discord for this avatar
|
||||
* @param options - Optional options for the avatar
|
||||
*/
|
||||
guildMemberAvatar(guildId: string, userId: string, avatarHash: string, options?: Readonly<ImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a guild member banner URL.
|
||||
*
|
||||
* @param guildId - The id of the guild
|
||||
* @param userId - The id of the user
|
||||
* @param bannerHash - The hash provided by Discord for this banner
|
||||
* @param options - Optional options for the banner
|
||||
*/
|
||||
guildMemberBanner(guildId: string, userId: string, bannerHash: string, options?: Readonly<ImageURLOptions>): string;
|
||||
/**
|
||||
* Generates an icon URL, e.g. for a guild.
|
||||
*
|
||||
* @param id - The id that has the icon splash
|
||||
* @param iconHash - The hash provided by Discord for this icon
|
||||
* @param options - Optional options for the icon
|
||||
*/
|
||||
icon(id: string, iconHash: string, options?: Readonly<ImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a URL for the icon of a role
|
||||
*
|
||||
* @param roleId - The id of the role that has the icon
|
||||
* @param roleIconHash - The hash provided by Discord for this role icon
|
||||
* @param options - Optional options for the role icon
|
||||
*/
|
||||
roleIcon(roleId: string, roleIconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a guild invite splash URL for a guild's invite splash.
|
||||
*
|
||||
* @param guildId - The guild id that has the invite splash
|
||||
* @param splashHash - The hash provided by Discord for this splash
|
||||
* @param options - Optional options for the splash
|
||||
*/
|
||||
splash(guildId: string, splashHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a sticker URL.
|
||||
*
|
||||
* @param stickerId - The sticker id
|
||||
* @param extension - The extension of the sticker
|
||||
* @privateRemarks
|
||||
* Stickers cannot have a `.webp` extension, so we default to a `.png`
|
||||
*/
|
||||
sticker(stickerId: string, extension?: StickerExtension): string;
|
||||
/**
|
||||
* Generates a sticker pack banner URL.
|
||||
*
|
||||
* @param bannerId - The banner id
|
||||
* @param options - Optional options for the banner
|
||||
*/
|
||||
stickerPackBanner(bannerId: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a team icon URL for a team's icon.
|
||||
*
|
||||
* @param teamId - The team id that has the icon
|
||||
* @param iconHash - The hash provided by Discord for this icon
|
||||
* @param options - Optional options for the icon
|
||||
*/
|
||||
teamIcon(teamId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a cover image for a guild scheduled event.
|
||||
*
|
||||
* @param scheduledEventId - The scheduled event id
|
||||
* @param coverHash - The hash provided by discord for this cover image
|
||||
* @param options - Optional options for the cover image
|
||||
*/
|
||||
guildScheduledEventCover(scheduledEventId: string, coverHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Constructs the URL for the resource, checking whether or not `hash` starts with `a_` if `dynamic` is set to `true`.
|
||||
*
|
||||
* @param route - The base cdn route
|
||||
* @param hash - The hash provided by Discord for this icon
|
||||
* @param options - Optional options for the link
|
||||
*/
|
||||
private dynamicMakeURL;
|
||||
/**
|
||||
* Constructs the URL for the resource
|
||||
*
|
||||
* @param route - The base cdn route
|
||||
* @param options - The extension/size options for the link
|
||||
*/
|
||||
private makeURL;
|
||||
}
|
||||
|
||||
interface DiscordErrorFieldInformation {
|
||||
code: string;
|
||||
message: string;
|
||||
}
|
||||
interface DiscordErrorGroupWrapper {
|
||||
_errors: DiscordError[];
|
||||
}
|
||||
type DiscordError = DiscordErrorFieldInformation | DiscordErrorGroupWrapper | string | {
|
||||
[k: string]: DiscordError;
|
||||
};
|
||||
interface DiscordErrorData {
|
||||
code: number;
|
||||
errors?: DiscordError;
|
||||
message: string;
|
||||
}
|
||||
interface OAuthErrorData {
|
||||
error: string;
|
||||
error_description?: string;
|
||||
}
|
||||
interface RequestBody {
|
||||
files: RawFile[] | undefined;
|
||||
json: unknown | undefined;
|
||||
}
|
||||
/**
|
||||
* Represents an API error returned by Discord
|
||||
*/
|
||||
declare class DiscordAPIError extends Error {
|
||||
rawError: DiscordErrorData | OAuthErrorData;
|
||||
code: number | string;
|
||||
status: number;
|
||||
method: string;
|
||||
url: string;
|
||||
requestBody: RequestBody;
|
||||
/**
|
||||
* @param rawError - The error reported by Discord
|
||||
* @param code - The error code reported by Discord
|
||||
* @param status - The status code of the response
|
||||
* @param method - The method of the request that erred
|
||||
* @param url - The url of the request that erred
|
||||
* @param bodyData - The unparsed data for the request that errored
|
||||
*/
|
||||
constructor(rawError: DiscordErrorData | OAuthErrorData, code: number | string, status: number, method: string, url: string, bodyData: Pick<InternalRequest, 'body' | 'files'>);
|
||||
/**
|
||||
* The name of the error
|
||||
*/
|
||||
get name(): string;
|
||||
private static getMessage;
|
||||
private static flattenDiscordError;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a HTTP error
|
||||
*/
|
||||
declare class HTTPError extends Error {
|
||||
status: number;
|
||||
method: string;
|
||||
url: string;
|
||||
requestBody: RequestBody;
|
||||
name: string;
|
||||
/**
|
||||
* @param status - The status code of the response
|
||||
* @param statusText - The status text of the response
|
||||
* @param method - The method of the request that erred
|
||||
* @param url - The url of the request that erred
|
||||
* @param bodyData - The unparsed data for the request that errored
|
||||
*/
|
||||
constructor(status: number, statusText: string, method: string, url: string, bodyData: Pick<InternalRequest, 'body' | 'files'>);
|
||||
}
|
||||
|
||||
declare class RateLimitError extends Error implements RateLimitData {
|
||||
timeToReset: number;
|
||||
limit: number;
|
||||
method: string;
|
||||
hash: string;
|
||||
url: string;
|
||||
route: string;
|
||||
majorParameter: string;
|
||||
global: boolean;
|
||||
retryAfter: number;
|
||||
sublimitTimeout: number;
|
||||
scope: RateLimitData['scope'];
|
||||
constructor({ timeToReset, limit, method, hash, url, route, majorParameter, global, retryAfter, sublimitTimeout, scope, }: RateLimitData);
|
||||
/**
|
||||
* The name of the error
|
||||
*/
|
||||
get name(): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the class that manages handlers for endpoints
|
||||
*/
|
||||
declare class REST extends AsyncEventEmitter<RestEventsMap> {
|
||||
#private;
|
||||
/**
|
||||
* The {@link https://undici.nodejs.org/#/docs/api/Agent | Agent} for all requests
|
||||
* performed by this manager.
|
||||
*/
|
||||
agent: Dispatcher | null;
|
||||
readonly cdn: CDN;
|
||||
/**
|
||||
* The number of requests remaining in the global bucket
|
||||
*/
|
||||
globalRemaining: number;
|
||||
/**
|
||||
* The promise used to wait out the global rate limit
|
||||
*/
|
||||
globalDelay: Promise<void> | null;
|
||||
/**
|
||||
* The timestamp at which the global bucket resets
|
||||
*/
|
||||
globalReset: number;
|
||||
/**
|
||||
* API bucket hashes that are cached from provided routes
|
||||
*/
|
||||
readonly hashes: Collection<string, HashData>;
|
||||
/**
|
||||
* Request handlers created from the bucket hash and the major parameters
|
||||
*/
|
||||
readonly handlers: Collection<string, IHandler>;
|
||||
private hashTimer;
|
||||
private handlerTimer;
|
||||
readonly options: RESTOptions;
|
||||
constructor(options?: Partial<RESTOptions>);
|
||||
private setupSweepers;
|
||||
/**
|
||||
* Runs a get request from the api
|
||||
*
|
||||
* @param fullRoute - The full route to query
|
||||
* @param options - Optional request options
|
||||
*/
|
||||
get(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||
/**
|
||||
* Runs a delete request from the api
|
||||
*
|
||||
* @param fullRoute - The full route to query
|
||||
* @param options - Optional request options
|
||||
*/
|
||||
delete(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||
/**
|
||||
* Runs a post request from the api
|
||||
*
|
||||
* @param fullRoute - The full route to query
|
||||
* @param options - Optional request options
|
||||
*/
|
||||
post(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||
/**
|
||||
* Runs a put request from the api
|
||||
*
|
||||
* @param fullRoute - The full route to query
|
||||
* @param options - Optional request options
|
||||
*/
|
||||
put(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||
/**
|
||||
* Runs a patch request from the api
|
||||
*
|
||||
* @param fullRoute - The full route to query
|
||||
* @param options - Optional request options
|
||||
*/
|
||||
patch(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||
/**
|
||||
* Runs a request from the api
|
||||
*
|
||||
* @param options - Request options
|
||||
*/
|
||||
request(options: InternalRequest): Promise<unknown>;
|
||||
/**
|
||||
* Sets the default agent to use for requests performed by this manager
|
||||
*
|
||||
* @param agent - The agent to use
|
||||
*/
|
||||
setAgent(agent: Dispatcher): this;
|
||||
/**
|
||||
* Sets the authorization token that should be used for requests
|
||||
*
|
||||
* @param token - The authorization token to use
|
||||
*/
|
||||
setToken(token: string): this;
|
||||
/**
|
||||
* Queues a request to be sent
|
||||
*
|
||||
* @param request - All the information needed to make a request
|
||||
* @returns The response from the api request
|
||||
*/
|
||||
queueRequest(request: InternalRequest): Promise<ResponseLike>;
|
||||
/**
|
||||
* Creates a new rate limit handler from a hash, based on the hash and the major parameter
|
||||
*
|
||||
* @param hash - The hash for the route
|
||||
* @param majorParameter - The major parameter for this handler
|
||||
* @internal
|
||||
*/
|
||||
private createHandler;
|
||||
/**
|
||||
* Formats the request data to a usable format for fetch
|
||||
*
|
||||
* @param request - The request data
|
||||
*/
|
||||
private resolveRequest;
|
||||
/**
|
||||
* Stops the hash sweeping interval
|
||||
*/
|
||||
clearHashSweeper(): void;
|
||||
/**
|
||||
* Stops the request handler sweeping interval
|
||||
*/
|
||||
clearHandlerSweeper(): void;
|
||||
/**
|
||||
* Generates route data for an endpoint:method
|
||||
*
|
||||
* @param endpoint - The raw endpoint to generalize
|
||||
* @param method - The HTTP method this endpoint is called without
|
||||
* @internal
|
||||
*/
|
||||
private static generateRouteData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and populates an URLSearchParams instance from an object, stripping
|
||||
* out null and undefined values, while also coercing non-strings to strings.
|
||||
*
|
||||
* @param options - The options to use
|
||||
* @returns A populated URLSearchParams instance
|
||||
*/
|
||||
declare function makeURLSearchParams<OptionsType extends object>(options?: Readonly<OptionsType>): url.URLSearchParams;
|
||||
/**
|
||||
* Converts the response to usable data
|
||||
*
|
||||
* @param res - The fetch response
|
||||
*/
|
||||
declare function parseResponse(res: ResponseLike): Promise<unknown>;
|
||||
/**
|
||||
* Calculates the default avatar index for a given user id.
|
||||
*
|
||||
* @param userId - The user id to calculate the default avatar index for
|
||||
*/
|
||||
declare function calculateUserDefaultAvatarIndex(userId: Snowflake): number;
|
||||
|
||||
/**
|
||||
* The {@link https://github.com/discordjs/discord.js/blob/main/packages/rest#readme | @discordjs/rest} version
|
||||
* that you are currently using.
|
||||
*/
|
||||
declare const version: string;
|
||||
|
||||
export { ALLOWED_EXTENSIONS, ALLOWED_SIZES, ALLOWED_STICKER_EXTENSIONS, APIRequest, BaseImageURLOptions, BurstHandlerMajorIdKey, CDN, DEPRECATION_WARNING_PREFIX, DefaultRestOptions, DefaultUserAgent, DefaultUserAgentAppendix, DiscordAPIError, DiscordErrorData, HTTPError, HandlerRequestData, HashData, ImageExtension, ImageSize, ImageURLOptions, InternalRequest, InvalidRequestWarningData, MakeURLOptions, OAuthErrorData, OverwrittenMimeTypes, REST, RESTEvents, RESTOptions, RateLimitData, RateLimitError, RateLimitQueueFilter, RawFile, RequestBody, RequestData, RequestHeaders, RequestMethod, ResponseLike, RestEvents, RestEventsMap, RouteData, RouteLike, StickerExtension, calculateUserDefaultAvatarIndex, makeURLSearchParams, parseResponse, version };
|
901
node_modules/@discordjs/rest/dist/index.d.ts
generated
vendored
Normal file
901
node_modules/@discordjs/rest/dist/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,901 @@
|
|||
import * as url from 'url';
|
||||
import { Snowflake } from 'discord-api-types/v10';
|
||||
import { Readable } from 'node:stream';
|
||||
import { ReadableStream } from 'node:stream/web';
|
||||
import { Collection } from '@discordjs/collection';
|
||||
import { Awaitable } from '@discordjs/util';
|
||||
import * as undici from 'undici';
|
||||
import { RequestInit, Dispatcher, Response, BodyInit, Agent } from 'undici';
|
||||
import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
|
||||
|
||||
interface IHandler {
|
||||
/**
|
||||
* The unique id of the handler
|
||||
*/
|
||||
readonly id: string;
|
||||
/**
|
||||
* If the bucket is currently inactive (no pending requests)
|
||||
*/
|
||||
get inactive(): boolean;
|
||||
/**
|
||||
* Queues a request to be sent
|
||||
*
|
||||
* @param routeId - The generalized api route with literal ids for major parameters
|
||||
* @param url - The url to do the request on
|
||||
* @param options - All the information needed to make a request
|
||||
* @param requestData - Extra data from the user's request needed for errors and additional processing
|
||||
*/
|
||||
queueRequest(routeId: RouteData, url: string, options: RequestInit, requestData: HandlerRequestData): Promise<ResponseLike>;
|
||||
}
|
||||
|
||||
interface RestEvents {
|
||||
handlerSweep: [sweptHandlers: Collection<string, IHandler>];
|
||||
hashSweep: [sweptHashes: Collection<string, HashData>];
|
||||
invalidRequestWarning: [invalidRequestInfo: InvalidRequestWarningData];
|
||||
rateLimited: [rateLimitInfo: RateLimitData];
|
||||
response: [request: APIRequest, response: ResponseLike];
|
||||
restDebug: [info: string];
|
||||
}
|
||||
type RestEventsMap = {
|
||||
[K in keyof RestEvents]: RestEvents[K];
|
||||
};
|
||||
/**
|
||||
* Options to be passed when creating the REST instance
|
||||
*/
|
||||
interface RESTOptions {
|
||||
/**
|
||||
* The agent to set globally
|
||||
*/
|
||||
agent: Dispatcher | null;
|
||||
/**
|
||||
* The base api path, without version
|
||||
*
|
||||
* @defaultValue `'https://discord.com/api'`
|
||||
*/
|
||||
api: string;
|
||||
/**
|
||||
* The authorization prefix to use for requests, useful if you want to use
|
||||
* bearer tokens
|
||||
*
|
||||
* @defaultValue `'Bot'`
|
||||
*/
|
||||
authPrefix: 'Bearer' | 'Bot';
|
||||
/**
|
||||
* The cdn path
|
||||
*
|
||||
* @defaultValue `'https://cdn.discordapp.com'`
|
||||
*/
|
||||
cdn: string;
|
||||
/**
|
||||
* How many requests to allow sending per second (Infinity for unlimited, 50 for the standard global limit used by Discord)
|
||||
*
|
||||
* @defaultValue `50`
|
||||
*/
|
||||
globalRequestsPerSecond: number;
|
||||
/**
|
||||
* The amount of time in milliseconds that passes between each hash sweep. (defaults to 1h)
|
||||
*
|
||||
* @defaultValue `3_600_000`
|
||||
*/
|
||||
handlerSweepInterval: number;
|
||||
/**
|
||||
* The maximum amount of time a hash can exist in milliseconds without being hit with a request (defaults to 24h)
|
||||
*
|
||||
* @defaultValue `86_400_000`
|
||||
*/
|
||||
hashLifetime: number;
|
||||
/**
|
||||
* The amount of time in milliseconds that passes between each hash sweep. (defaults to 4h)
|
||||
*
|
||||
* @defaultValue `14_400_000`
|
||||
*/
|
||||
hashSweepInterval: number;
|
||||
/**
|
||||
* Additional headers to send for all API requests
|
||||
*
|
||||
* @defaultValue `{}`
|
||||
*/
|
||||
headers: Record<string, string>;
|
||||
/**
|
||||
* The number of invalid REST requests (those that return 401, 403, or 429) in a 10 minute window between emitted warnings (0 for no warnings).
|
||||
* That is, if set to 500, warnings will be emitted at invalid request number 500, 1000, 1500, and so on.
|
||||
*
|
||||
* @defaultValue `0`
|
||||
*/
|
||||
invalidRequestWarningInterval: number;
|
||||
/**
|
||||
* The method called to perform the actual HTTP request given a url and web `fetch` options
|
||||
* For example, to use global fetch, simply provide `makeRequest: fetch`
|
||||
*/
|
||||
makeRequest(url: string, init: RequestInit): Promise<ResponseLike>;
|
||||
/**
|
||||
* The extra offset to add to rate limits in milliseconds
|
||||
*
|
||||
* @defaultValue `50`
|
||||
*/
|
||||
offset: number;
|
||||
/**
|
||||
* Determines how rate limiting and pre-emptive throttling should be handled.
|
||||
* When an array of strings, each element is treated as a prefix for the request route
|
||||
* (e.g. `/channels` to match any route starting with `/channels` such as `/channels/:id/messages`)
|
||||
* for which to throw {@link RateLimitError}s. All other request routes will be queued normally
|
||||
*
|
||||
* @defaultValue `null`
|
||||
*/
|
||||
rejectOnRateLimit: RateLimitQueueFilter | string[] | null;
|
||||
/**
|
||||
* The number of retries for errors with the 500 code, or errors
|
||||
* that timeout
|
||||
*
|
||||
* @defaultValue `3`
|
||||
*/
|
||||
retries: number;
|
||||
/**
|
||||
* The time to wait in milliseconds before a request is aborted
|
||||
*
|
||||
* @defaultValue `15_000`
|
||||
*/
|
||||
timeout: number;
|
||||
/**
|
||||
* Extra information to add to the user agent
|
||||
*
|
||||
* @defaultValue DefaultUserAgentAppendix
|
||||
*/
|
||||
userAgentAppendix: string;
|
||||
/**
|
||||
* The version of the API to use
|
||||
*
|
||||
* @defaultValue `'10'`
|
||||
*/
|
||||
version: string;
|
||||
}
|
||||
/**
|
||||
* Data emitted on `RESTEvents.RateLimited`
|
||||
*/
|
||||
interface RateLimitData {
|
||||
/**
|
||||
* Whether the rate limit that was reached was the global limit
|
||||
*/
|
||||
global: boolean;
|
||||
/**
|
||||
* The bucket hash for this request
|
||||
*/
|
||||
hash: string;
|
||||
/**
|
||||
* The amount of requests we can perform before locking requests
|
||||
*/
|
||||
limit: number;
|
||||
/**
|
||||
* The major parameter of the route
|
||||
*
|
||||
* For example, in `/channels/x`, this will be `x`.
|
||||
* If there is no major parameter (e.g: `/bot/gateway`) this will be `global`.
|
||||
*/
|
||||
majorParameter: string;
|
||||
/**
|
||||
* The HTTP method being performed
|
||||
*/
|
||||
method: string;
|
||||
/**
|
||||
* The time, in milliseconds, that will need to pass before this specific request can be retried
|
||||
*/
|
||||
retryAfter: number;
|
||||
/**
|
||||
* The route being hit in this request
|
||||
*/
|
||||
route: string;
|
||||
/**
|
||||
* The scope of the rate limit that was hit.
|
||||
*
|
||||
* This can be `user` for rate limits that are per client, `global` for rate limits that affect all clients or `shared` for rate limits that
|
||||
* are shared per resource.
|
||||
*/
|
||||
scope: 'global' | 'shared' | 'user';
|
||||
/**
|
||||
* The time, in milliseconds, that will need to pass before the sublimit lock for the route resets, and requests that fall under a sublimit
|
||||
* can be retried
|
||||
*
|
||||
* This is only present on certain sublimits, and `0` otherwise
|
||||
*/
|
||||
sublimitTimeout: number;
|
||||
/**
|
||||
* The time, in milliseconds, until the route's request-lock is reset
|
||||
*/
|
||||
timeToReset: number;
|
||||
/**
|
||||
* The full URL for this request
|
||||
*/
|
||||
url: string;
|
||||
}
|
||||
/**
|
||||
* A function that determines whether the rate limit hit should throw an Error
|
||||
*/
|
||||
type RateLimitQueueFilter = (rateLimitData: RateLimitData) => Awaitable<boolean>;
|
||||
interface APIRequest {
|
||||
/**
|
||||
* The data that was used to form the body of this request
|
||||
*/
|
||||
data: HandlerRequestData;
|
||||
/**
|
||||
* The HTTP method used in this request
|
||||
*/
|
||||
method: string;
|
||||
/**
|
||||
* Additional HTTP options for this request
|
||||
*/
|
||||
options: RequestInit;
|
||||
/**
|
||||
* The full path used to make the request
|
||||
*/
|
||||
path: RouteLike;
|
||||
/**
|
||||
* The number of times this request has been attempted
|
||||
*/
|
||||
retries: number;
|
||||
/**
|
||||
* The API route identifying the ratelimit for this request
|
||||
*/
|
||||
route: string;
|
||||
}
|
||||
interface ResponseLike extends Pick<Response, 'arrayBuffer' | 'bodyUsed' | 'headers' | 'json' | 'ok' | 'status' | 'statusText' | 'text'> {
|
||||
body: Readable | ReadableStream | null;
|
||||
}
|
||||
interface InvalidRequestWarningData {
|
||||
/**
|
||||
* Number of invalid requests that have been made in the window
|
||||
*/
|
||||
count: number;
|
||||
/**
|
||||
* Time in milliseconds remaining before the count resets
|
||||
*/
|
||||
remainingTime: number;
|
||||
}
|
||||
/**
|
||||
* Represents a file to be added to the request
|
||||
*/
|
||||
interface RawFile {
|
||||
/**
|
||||
* Content-Type of the file
|
||||
*/
|
||||
contentType?: string;
|
||||
/**
|
||||
* The actual data for the file
|
||||
*/
|
||||
data: Buffer | Uint8Array | boolean | number | string;
|
||||
/**
|
||||
* An explicit key to use for key of the formdata field for this file.
|
||||
* When not provided, the index of the file in the files array is used in the form `files[${index}]`.
|
||||
* If you wish to alter the placeholder snowflake, you must provide this property in the same form (`files[${placeholder}]`)
|
||||
*/
|
||||
key?: string;
|
||||
/**
|
||||
* The name of the file
|
||||
*/
|
||||
name: string;
|
||||
}
|
||||
/**
|
||||
* Represents possible data to be given to an endpoint
|
||||
*/
|
||||
interface RequestData {
|
||||
/**
|
||||
* Whether to append JSON data to form data instead of `payload_json` when sending files
|
||||
*/
|
||||
appendToFormData?: boolean;
|
||||
/**
|
||||
* If this request needs the `Authorization` header
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
auth?: boolean;
|
||||
/**
|
||||
* The authorization prefix to use for this request, useful if you use this with bearer tokens
|
||||
*
|
||||
* @defaultValue `'Bot'`
|
||||
*/
|
||||
authPrefix?: 'Bearer' | 'Bot';
|
||||
/**
|
||||
* The body to send to this request.
|
||||
* If providing as BodyInit, set `passThroughBody: true`
|
||||
*/
|
||||
body?: BodyInit | unknown;
|
||||
/**
|
||||
* The {@link https://undici.nodejs.org/#/docs/api/Agent | Agent} to use for the request.
|
||||
*/
|
||||
dispatcher?: Agent;
|
||||
/**
|
||||
* Files to be attached to this request
|
||||
*/
|
||||
files?: RawFile[] | undefined;
|
||||
/**
|
||||
* Additional headers to add to this request
|
||||
*/
|
||||
headers?: Record<string, string>;
|
||||
/**
|
||||
* Whether to pass-through the body property directly to `fetch()`.
|
||||
* <warn>This only applies when files is NOT present</warn>
|
||||
*/
|
||||
passThroughBody?: boolean;
|
||||
/**
|
||||
* Query string parameters to append to the called endpoint
|
||||
*/
|
||||
query?: URLSearchParams;
|
||||
/**
|
||||
* Reason to show in the audit logs
|
||||
*/
|
||||
reason?: string | undefined;
|
||||
/**
|
||||
* The signal to abort the queue entry or the REST call, where applicable
|
||||
*/
|
||||
signal?: AbortSignal | undefined;
|
||||
/**
|
||||
* If this request should be versioned
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
versioned?: boolean;
|
||||
}
|
||||
/**
|
||||
* Possible headers for an API call
|
||||
*/
|
||||
interface RequestHeaders {
|
||||
Authorization?: string;
|
||||
'User-Agent': string;
|
||||
'X-Audit-Log-Reason'?: string;
|
||||
}
|
||||
/**
|
||||
* Possible API methods to be used when doing requests
|
||||
*/
|
||||
declare enum RequestMethod {
|
||||
Delete = "DELETE",
|
||||
Get = "GET",
|
||||
Patch = "PATCH",
|
||||
Post = "POST",
|
||||
Put = "PUT"
|
||||
}
|
||||
type RouteLike = `/${string}`;
|
||||
/**
|
||||
* Internal request options
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface InternalRequest extends RequestData {
|
||||
fullRoute: RouteLike;
|
||||
method: RequestMethod;
|
||||
}
|
||||
type HandlerRequestData = Pick<InternalRequest, 'auth' | 'body' | 'files' | 'signal'>;
|
||||
/**
|
||||
* Parsed route data for an endpoint
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface RouteData {
|
||||
bucketRoute: string;
|
||||
majorParameter: string;
|
||||
original: RouteLike;
|
||||
}
|
||||
/**
|
||||
* Represents a hash and its associated fields
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface HashData {
|
||||
lastAccess: number;
|
||||
value: string;
|
||||
}
|
||||
|
||||
declare const DefaultUserAgent: `DiscordBot (https://discord.js.org, ${string})`;
|
||||
/**
|
||||
* The default string to append onto the user agent.
|
||||
*/
|
||||
declare const DefaultUserAgentAppendix: string;
|
||||
declare const DefaultRestOptions: {
|
||||
readonly agent: null;
|
||||
readonly api: "https://discord.com/api";
|
||||
readonly authPrefix: "Bot";
|
||||
readonly cdn: "https://cdn.discordapp.com";
|
||||
readonly headers: {};
|
||||
readonly invalidRequestWarningInterval: 0;
|
||||
readonly globalRequestsPerSecond: 50;
|
||||
readonly offset: 50;
|
||||
readonly rejectOnRateLimit: null;
|
||||
readonly retries: 3;
|
||||
readonly timeout: 15000;
|
||||
readonly userAgentAppendix: string;
|
||||
readonly version: "10";
|
||||
readonly hashSweepInterval: 14400000;
|
||||
readonly hashLifetime: 86400000;
|
||||
readonly handlerSweepInterval: 3600000;
|
||||
readonly makeRequest: (url: string, init: undici.RequestInit) => Promise<ResponseLike>;
|
||||
};
|
||||
/**
|
||||
* The events that the REST manager emits
|
||||
*/
|
||||
declare enum RESTEvents {
|
||||
Debug = "restDebug",
|
||||
HandlerSweep = "handlerSweep",
|
||||
HashSweep = "hashSweep",
|
||||
InvalidRequestWarning = "invalidRequestWarning",
|
||||
RateLimited = "rateLimited",
|
||||
Response = "response"
|
||||
}
|
||||
declare const ALLOWED_EXTENSIONS: readonly ["webp", "png", "jpg", "jpeg", "gif"];
|
||||
declare const ALLOWED_STICKER_EXTENSIONS: readonly ["png", "json", "gif"];
|
||||
declare const ALLOWED_SIZES: readonly [16, 32, 64, 128, 256, 512, 1024, 2048, 4096];
|
||||
type ImageExtension = (typeof ALLOWED_EXTENSIONS)[number];
|
||||
type StickerExtension = (typeof ALLOWED_STICKER_EXTENSIONS)[number];
|
||||
type ImageSize = (typeof ALLOWED_SIZES)[number];
|
||||
declare const OverwrittenMimeTypes: {
|
||||
readonly 'image/apng': "image/png";
|
||||
};
|
||||
declare const BurstHandlerMajorIdKey = "burst";
|
||||
/**
|
||||
* Prefix for deprecation warnings.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
declare const DEPRECATION_WARNING_PREFIX: "DeprecationWarning";
|
||||
|
||||
/**
|
||||
* The options used for image URLs
|
||||
*/
|
||||
interface BaseImageURLOptions {
|
||||
/**
|
||||
* The extension to use for the image URL
|
||||
*
|
||||
* @defaultValue `'webp'`
|
||||
*/
|
||||
extension?: ImageExtension;
|
||||
/**
|
||||
* The size specified in the image URL
|
||||
*/
|
||||
size?: ImageSize;
|
||||
}
|
||||
/**
|
||||
* The options used for image URLs with animated content
|
||||
*/
|
||||
interface ImageURLOptions extends BaseImageURLOptions {
|
||||
/**
|
||||
* Whether or not to prefer the static version of an image asset.
|
||||
*/
|
||||
forceStatic?: boolean;
|
||||
}
|
||||
/**
|
||||
* The options to use when making a CDN URL
|
||||
*/
|
||||
interface MakeURLOptions {
|
||||
/**
|
||||
* The allowed extensions that can be used
|
||||
*/
|
||||
allowedExtensions?: readonly string[];
|
||||
/**
|
||||
* The extension to use for the image URL
|
||||
*
|
||||
* @defaultValue `'webp'`
|
||||
*/
|
||||
extension?: string | undefined;
|
||||
/**
|
||||
* The size specified in the image URL
|
||||
*/
|
||||
size?: ImageSize;
|
||||
}
|
||||
/**
|
||||
* The CDN link builder
|
||||
*/
|
||||
declare class CDN {
|
||||
private readonly base;
|
||||
constructor(base?: string);
|
||||
/**
|
||||
* Generates an app asset URL for a client's asset.
|
||||
*
|
||||
* @param clientId - The client id that has the asset
|
||||
* @param assetHash - The hash provided by Discord for this asset
|
||||
* @param options - Optional options for the asset
|
||||
*/
|
||||
appAsset(clientId: string, assetHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates an app icon URL for a client's icon.
|
||||
*
|
||||
* @param clientId - The client id that has the icon
|
||||
* @param iconHash - The hash provided by Discord for this icon
|
||||
* @param options - Optional options for the icon
|
||||
*/
|
||||
appIcon(clientId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates an avatar URL, e.g. for a user or a webhook.
|
||||
*
|
||||
* @param id - The id that has the icon
|
||||
* @param avatarHash - The hash provided by Discord for this avatar
|
||||
* @param options - Optional options for the avatar
|
||||
*/
|
||||
avatar(id: string, avatarHash: string, options?: Readonly<ImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a user avatar decoration URL.
|
||||
*
|
||||
* @param userId - The id of the user
|
||||
* @param userAvatarDecoration - The hash provided by Discord for this avatar decoration
|
||||
* @param options - Optional options for the avatar decoration
|
||||
*/
|
||||
avatarDecoration(userId: string, userAvatarDecoration: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a banner URL, e.g. for a user or a guild.
|
||||
*
|
||||
* @param id - The id that has the banner splash
|
||||
* @param bannerHash - The hash provided by Discord for this banner
|
||||
* @param options - Optional options for the banner
|
||||
*/
|
||||
banner(id: string, bannerHash: string, options?: Readonly<ImageURLOptions>): string;
|
||||
/**
|
||||
* Generates an icon URL for a channel, e.g. a group DM.
|
||||
*
|
||||
* @param channelId - The channel id that has the icon
|
||||
* @param iconHash - The hash provided by Discord for this channel
|
||||
* @param options - Optional options for the icon
|
||||
*/
|
||||
channelIcon(channelId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a default avatar URL
|
||||
*
|
||||
* @param index - The default avatar index
|
||||
* @remarks
|
||||
* To calculate the index for a user do `(userId >> 22) % 6`,
|
||||
* or `discriminator % 5` if they're using the legacy username system.
|
||||
*/
|
||||
defaultAvatar(index: number): string;
|
||||
/**
|
||||
* Generates a discovery splash URL for a guild's discovery splash.
|
||||
*
|
||||
* @param guildId - The guild id that has the discovery splash
|
||||
* @param splashHash - The hash provided by Discord for this splash
|
||||
* @param options - Optional options for the splash
|
||||
*/
|
||||
discoverySplash(guildId: string, splashHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates an emoji's URL for an emoji.
|
||||
*
|
||||
* @param emojiId - The emoji id
|
||||
* @param options - Optional options for the emoji
|
||||
*/
|
||||
emoji(emojiId: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates an emoji's URL for an emoji.
|
||||
*
|
||||
* @param emojiId - The emoji id
|
||||
* @param extension - The extension of the emoji
|
||||
* @deprecated This overload is deprecated. Pass an object containing the extension instead.
|
||||
*/
|
||||
emoji(emojiId: string, extension?: ImageExtension): string;
|
||||
/**
|
||||
* Generates a guild member avatar URL.
|
||||
*
|
||||
* @param guildId - The id of the guild
|
||||
* @param userId - The id of the user
|
||||
* @param avatarHash - The hash provided by Discord for this avatar
|
||||
* @param options - Optional options for the avatar
|
||||
*/
|
||||
guildMemberAvatar(guildId: string, userId: string, avatarHash: string, options?: Readonly<ImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a guild member banner URL.
|
||||
*
|
||||
* @param guildId - The id of the guild
|
||||
* @param userId - The id of the user
|
||||
* @param bannerHash - The hash provided by Discord for this banner
|
||||
* @param options - Optional options for the banner
|
||||
*/
|
||||
guildMemberBanner(guildId: string, userId: string, bannerHash: string, options?: Readonly<ImageURLOptions>): string;
|
||||
/**
|
||||
* Generates an icon URL, e.g. for a guild.
|
||||
*
|
||||
* @param id - The id that has the icon splash
|
||||
* @param iconHash - The hash provided by Discord for this icon
|
||||
* @param options - Optional options for the icon
|
||||
*/
|
||||
icon(id: string, iconHash: string, options?: Readonly<ImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a URL for the icon of a role
|
||||
*
|
||||
* @param roleId - The id of the role that has the icon
|
||||
* @param roleIconHash - The hash provided by Discord for this role icon
|
||||
* @param options - Optional options for the role icon
|
||||
*/
|
||||
roleIcon(roleId: string, roleIconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a guild invite splash URL for a guild's invite splash.
|
||||
*
|
||||
* @param guildId - The guild id that has the invite splash
|
||||
* @param splashHash - The hash provided by Discord for this splash
|
||||
* @param options - Optional options for the splash
|
||||
*/
|
||||
splash(guildId: string, splashHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a sticker URL.
|
||||
*
|
||||
* @param stickerId - The sticker id
|
||||
* @param extension - The extension of the sticker
|
||||
* @privateRemarks
|
||||
* Stickers cannot have a `.webp` extension, so we default to a `.png`
|
||||
*/
|
||||
sticker(stickerId: string, extension?: StickerExtension): string;
|
||||
/**
|
||||
* Generates a sticker pack banner URL.
|
||||
*
|
||||
* @param bannerId - The banner id
|
||||
* @param options - Optional options for the banner
|
||||
*/
|
||||
stickerPackBanner(bannerId: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a team icon URL for a team's icon.
|
||||
*
|
||||
* @param teamId - The team id that has the icon
|
||||
* @param iconHash - The hash provided by Discord for this icon
|
||||
* @param options - Optional options for the icon
|
||||
*/
|
||||
teamIcon(teamId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a cover image for a guild scheduled event.
|
||||
*
|
||||
* @param scheduledEventId - The scheduled event id
|
||||
* @param coverHash - The hash provided by discord for this cover image
|
||||
* @param options - Optional options for the cover image
|
||||
*/
|
||||
guildScheduledEventCover(scheduledEventId: string, coverHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Constructs the URL for the resource, checking whether or not `hash` starts with `a_` if `dynamic` is set to `true`.
|
||||
*
|
||||
* @param route - The base cdn route
|
||||
* @param hash - The hash provided by Discord for this icon
|
||||
* @param options - Optional options for the link
|
||||
*/
|
||||
private dynamicMakeURL;
|
||||
/**
|
||||
* Constructs the URL for the resource
|
||||
*
|
||||
* @param route - The base cdn route
|
||||
* @param options - The extension/size options for the link
|
||||
*/
|
||||
private makeURL;
|
||||
}
|
||||
|
||||
interface DiscordErrorFieldInformation {
|
||||
code: string;
|
||||
message: string;
|
||||
}
|
||||
interface DiscordErrorGroupWrapper {
|
||||
_errors: DiscordError[];
|
||||
}
|
||||
type DiscordError = DiscordErrorFieldInformation | DiscordErrorGroupWrapper | string | {
|
||||
[k: string]: DiscordError;
|
||||
};
|
||||
interface DiscordErrorData {
|
||||
code: number;
|
||||
errors?: DiscordError;
|
||||
message: string;
|
||||
}
|
||||
interface OAuthErrorData {
|
||||
error: string;
|
||||
error_description?: string;
|
||||
}
|
||||
interface RequestBody {
|
||||
files: RawFile[] | undefined;
|
||||
json: unknown | undefined;
|
||||
}
|
||||
/**
|
||||
* Represents an API error returned by Discord
|
||||
*/
|
||||
declare class DiscordAPIError extends Error {
|
||||
rawError: DiscordErrorData | OAuthErrorData;
|
||||
code: number | string;
|
||||
status: number;
|
||||
method: string;
|
||||
url: string;
|
||||
requestBody: RequestBody;
|
||||
/**
|
||||
* @param rawError - The error reported by Discord
|
||||
* @param code - The error code reported by Discord
|
||||
* @param status - The status code of the response
|
||||
* @param method - The method of the request that erred
|
||||
* @param url - The url of the request that erred
|
||||
* @param bodyData - The unparsed data for the request that errored
|
||||
*/
|
||||
constructor(rawError: DiscordErrorData | OAuthErrorData, code: number | string, status: number, method: string, url: string, bodyData: Pick<InternalRequest, 'body' | 'files'>);
|
||||
/**
|
||||
* The name of the error
|
||||
*/
|
||||
get name(): string;
|
||||
private static getMessage;
|
||||
private static flattenDiscordError;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a HTTP error
|
||||
*/
|
||||
declare class HTTPError extends Error {
|
||||
status: number;
|
||||
method: string;
|
||||
url: string;
|
||||
requestBody: RequestBody;
|
||||
name: string;
|
||||
/**
|
||||
* @param status - The status code of the response
|
||||
* @param statusText - The status text of the response
|
||||
* @param method - The method of the request that erred
|
||||
* @param url - The url of the request that erred
|
||||
* @param bodyData - The unparsed data for the request that errored
|
||||
*/
|
||||
constructor(status: number, statusText: string, method: string, url: string, bodyData: Pick<InternalRequest, 'body' | 'files'>);
|
||||
}
|
||||
|
||||
declare class RateLimitError extends Error implements RateLimitData {
|
||||
timeToReset: number;
|
||||
limit: number;
|
||||
method: string;
|
||||
hash: string;
|
||||
url: string;
|
||||
route: string;
|
||||
majorParameter: string;
|
||||
global: boolean;
|
||||
retryAfter: number;
|
||||
sublimitTimeout: number;
|
||||
scope: RateLimitData['scope'];
|
||||
constructor({ timeToReset, limit, method, hash, url, route, majorParameter, global, retryAfter, sublimitTimeout, scope, }: RateLimitData);
|
||||
/**
|
||||
* The name of the error
|
||||
*/
|
||||
get name(): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the class that manages handlers for endpoints
|
||||
*/
|
||||
declare class REST extends AsyncEventEmitter<RestEventsMap> {
|
||||
#private;
|
||||
/**
|
||||
* The {@link https://undici.nodejs.org/#/docs/api/Agent | Agent} for all requests
|
||||
* performed by this manager.
|
||||
*/
|
||||
agent: Dispatcher | null;
|
||||
readonly cdn: CDN;
|
||||
/**
|
||||
* The number of requests remaining in the global bucket
|
||||
*/
|
||||
globalRemaining: number;
|
||||
/**
|
||||
* The promise used to wait out the global rate limit
|
||||
*/
|
||||
globalDelay: Promise<void> | null;
|
||||
/**
|
||||
* The timestamp at which the global bucket resets
|
||||
*/
|
||||
globalReset: number;
|
||||
/**
|
||||
* API bucket hashes that are cached from provided routes
|
||||
*/
|
||||
readonly hashes: Collection<string, HashData>;
|
||||
/**
|
||||
* Request handlers created from the bucket hash and the major parameters
|
||||
*/
|
||||
readonly handlers: Collection<string, IHandler>;
|
||||
private hashTimer;
|
||||
private handlerTimer;
|
||||
readonly options: RESTOptions;
|
||||
constructor(options?: Partial<RESTOptions>);
|
||||
private setupSweepers;
|
||||
/**
|
||||
* Runs a get request from the api
|
||||
*
|
||||
* @param fullRoute - The full route to query
|
||||
* @param options - Optional request options
|
||||
*/
|
||||
get(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||
/**
|
||||
* Runs a delete request from the api
|
||||
*
|
||||
* @param fullRoute - The full route to query
|
||||
* @param options - Optional request options
|
||||
*/
|
||||
delete(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||
/**
|
||||
* Runs a post request from the api
|
||||
*
|
||||
* @param fullRoute - The full route to query
|
||||
* @param options - Optional request options
|
||||
*/
|
||||
post(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||
/**
|
||||
* Runs a put request from the api
|
||||
*
|
||||
* @param fullRoute - The full route to query
|
||||
* @param options - Optional request options
|
||||
*/
|
||||
put(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||
/**
|
||||
* Runs a patch request from the api
|
||||
*
|
||||
* @param fullRoute - The full route to query
|
||||
* @param options - Optional request options
|
||||
*/
|
||||
patch(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||
/**
|
||||
* Runs a request from the api
|
||||
*
|
||||
* @param options - Request options
|
||||
*/
|
||||
request(options: InternalRequest): Promise<unknown>;
|
||||
/**
|
||||
* Sets the default agent to use for requests performed by this manager
|
||||
*
|
||||
* @param agent - The agent to use
|
||||
*/
|
||||
setAgent(agent: Dispatcher): this;
|
||||
/**
|
||||
* Sets the authorization token that should be used for requests
|
||||
*
|
||||
* @param token - The authorization token to use
|
||||
*/
|
||||
setToken(token: string): this;
|
||||
/**
|
||||
* Queues a request to be sent
|
||||
*
|
||||
* @param request - All the information needed to make a request
|
||||
* @returns The response from the api request
|
||||
*/
|
||||
queueRequest(request: InternalRequest): Promise<ResponseLike>;
|
||||
/**
|
||||
* Creates a new rate limit handler from a hash, based on the hash and the major parameter
|
||||
*
|
||||
* @param hash - The hash for the route
|
||||
* @param majorParameter - The major parameter for this handler
|
||||
* @internal
|
||||
*/
|
||||
private createHandler;
|
||||
/**
|
||||
* Formats the request data to a usable format for fetch
|
||||
*
|
||||
* @param request - The request data
|
||||
*/
|
||||
private resolveRequest;
|
||||
/**
|
||||
* Stops the hash sweeping interval
|
||||
*/
|
||||
clearHashSweeper(): void;
|
||||
/**
|
||||
* Stops the request handler sweeping interval
|
||||
*/
|
||||
clearHandlerSweeper(): void;
|
||||
/**
|
||||
* Generates route data for an endpoint:method
|
||||
*
|
||||
* @param endpoint - The raw endpoint to generalize
|
||||
* @param method - The HTTP method this endpoint is called without
|
||||
* @internal
|
||||
*/
|
||||
private static generateRouteData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and populates an URLSearchParams instance from an object, stripping
|
||||
* out null and undefined values, while also coercing non-strings to strings.
|
||||
*
|
||||
* @param options - The options to use
|
||||
* @returns A populated URLSearchParams instance
|
||||
*/
|
||||
declare function makeURLSearchParams<OptionsType extends object>(options?: Readonly<OptionsType>): url.URLSearchParams;
|
||||
/**
|
||||
* Converts the response to usable data
|
||||
*
|
||||
* @param res - The fetch response
|
||||
*/
|
||||
declare function parseResponse(res: ResponseLike): Promise<unknown>;
|
||||
/**
|
||||
* Calculates the default avatar index for a given user id.
|
||||
*
|
||||
* @param userId - The user id to calculate the default avatar index for
|
||||
*/
|
||||
declare function calculateUserDefaultAvatarIndex(userId: Snowflake): number;
|
||||
|
||||
/**
|
||||
* The {@link https://github.com/discordjs/discord.js/blob/main/packages/rest#readme | @discordjs/rest} version
|
||||
* that you are currently using.
|
||||
*/
|
||||
declare const version: string;
|
||||
|
||||
export { ALLOWED_EXTENSIONS, ALLOWED_SIZES, ALLOWED_STICKER_EXTENSIONS, APIRequest, BaseImageURLOptions, BurstHandlerMajorIdKey, CDN, DEPRECATION_WARNING_PREFIX, DefaultRestOptions, DefaultUserAgent, DefaultUserAgentAppendix, DiscordAPIError, DiscordErrorData, HTTPError, HandlerRequestData, HashData, ImageExtension, ImageSize, ImageURLOptions, InternalRequest, InvalidRequestWarningData, MakeURLOptions, OAuthErrorData, OverwrittenMimeTypes, REST, RESTEvents, RESTOptions, RateLimitData, RateLimitError, RateLimitQueueFilter, RawFile, RequestBody, RequestData, RequestHeaders, RequestMethod, ResponseLike, RestEvents, RestEventsMap, RouteData, RouteLike, StickerExtension, calculateUserDefaultAvatarIndex, makeURLSearchParams, parseResponse, version };
|
1474
node_modules/@discordjs/rest/dist/index.js
generated
vendored
Normal file
1474
node_modules/@discordjs/rest/dist/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
node_modules/@discordjs/rest/dist/index.js.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/dist/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1432
node_modules/@discordjs/rest/dist/index.mjs
generated
vendored
Normal file
1432
node_modules/@discordjs/rest/dist/index.mjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
node_modules/@discordjs/rest/dist/index.mjs.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/dist/index.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
13
node_modules/@discordjs/rest/dist/strategies/undiciRequest.d.mts
generated
vendored
Normal file
13
node_modules/@discordjs/rest/dist/strategies/undiciRequest.d.mts
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
import { Response, request, RequestInit } from 'undici';
|
||||
import { Readable } from 'node:stream';
|
||||
import { ReadableStream } from 'node:stream/web';
|
||||
|
||||
interface ResponseLike extends Pick<Response, 'arrayBuffer' | 'bodyUsed' | 'headers' | 'json' | 'ok' | 'status' | 'statusText' | 'text'> {
|
||||
body: Readable | ReadableStream | null;
|
||||
}
|
||||
|
||||
type RequestOptions = Exclude<Parameters<typeof request>[1], undefined>;
|
||||
declare function makeRequest(url: string, init: RequestInit): Promise<ResponseLike>;
|
||||
declare function resolveBody(body: RequestInit['body']): Promise<Exclude<RequestOptions['body'], undefined>>;
|
||||
|
||||
export { RequestOptions, makeRequest, resolveBody };
|
13
node_modules/@discordjs/rest/dist/strategies/undiciRequest.d.ts
generated
vendored
Normal file
13
node_modules/@discordjs/rest/dist/strategies/undiciRequest.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
import { Response, request, RequestInit } from 'undici';
|
||||
import { Readable } from 'node:stream';
|
||||
import { ReadableStream } from 'node:stream/web';
|
||||
|
||||
interface ResponseLike extends Pick<Response, 'arrayBuffer' | 'bodyUsed' | 'headers' | 'json' | 'ok' | 'status' | 'statusText' | 'text'> {
|
||||
body: Readable | ReadableStream | null;
|
||||
}
|
||||
|
||||
type RequestOptions = Exclude<Parameters<typeof request>[1], undefined>;
|
||||
declare function makeRequest(url: string, init: RequestInit): Promise<ResponseLike>;
|
||||
declare function resolveBody(body: RequestInit['body']): Promise<Exclude<RequestOptions['body'], undefined>>;
|
||||
|
||||
export { RequestOptions, makeRequest, resolveBody };
|
94
node_modules/@discordjs/rest/dist/strategies/undiciRequest.js
generated
vendored
Normal file
94
node_modules/@discordjs/rest/dist/strategies/undiciRequest.js
generated
vendored
Normal file
|
@ -0,0 +1,94 @@
|
|||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/strategies/undiciRequest.ts
|
||||
var undiciRequest_exports = {};
|
||||
__export(undiciRequest_exports, {
|
||||
makeRequest: () => makeRequest,
|
||||
resolveBody: () => resolveBody
|
||||
});
|
||||
module.exports = __toCommonJS(undiciRequest_exports);
|
||||
var import_node_http = require("http");
|
||||
var import_node_url = require("url");
|
||||
var import_node_util = require("util");
|
||||
var import_undici = require("undici");
|
||||
async function makeRequest(url, init) {
|
||||
const options = {
|
||||
...init,
|
||||
body: await resolveBody(init.body)
|
||||
};
|
||||
const res = await (0, import_undici.request)(url, options);
|
||||
return {
|
||||
body: res.body,
|
||||
async arrayBuffer() {
|
||||
return res.body.arrayBuffer();
|
||||
},
|
||||
async json() {
|
||||
return res.body.json();
|
||||
},
|
||||
async text() {
|
||||
return res.body.text();
|
||||
},
|
||||
get bodyUsed() {
|
||||
return res.body.bodyUsed;
|
||||
},
|
||||
headers: new import_undici.Headers(res.headers),
|
||||
status: res.statusCode,
|
||||
statusText: import_node_http.STATUS_CODES[res.statusCode],
|
||||
ok: res.statusCode >= 200 && res.statusCode < 300
|
||||
};
|
||||
}
|
||||
__name(makeRequest, "makeRequest");
|
||||
async function resolveBody(body) {
|
||||
if (body == null) {
|
||||
return null;
|
||||
} else if (typeof body === "string") {
|
||||
return body;
|
||||
} else if (import_node_util.types.isUint8Array(body)) {
|
||||
return body;
|
||||
} else if (import_node_util.types.isArrayBuffer(body)) {
|
||||
return new Uint8Array(body);
|
||||
} else if (body instanceof import_node_url.URLSearchParams) {
|
||||
return body.toString();
|
||||
} else if (body instanceof DataView) {
|
||||
return new Uint8Array(body.buffer);
|
||||
} else if (body instanceof Blob) {
|
||||
return new Uint8Array(await body.arrayBuffer());
|
||||
} else if (body instanceof FormData) {
|
||||
return body;
|
||||
} else if (body[Symbol.iterator]) {
|
||||
const chunks = [...body];
|
||||
return Buffer.concat(chunks);
|
||||
} else if (body[Symbol.asyncIterator]) {
|
||||
const chunks = [];
|
||||
for await (const chunk of body) {
|
||||
chunks.push(chunk);
|
||||
}
|
||||
return Buffer.concat(chunks);
|
||||
}
|
||||
throw new TypeError(`Unable to resolve body.`);
|
||||
}
|
||||
__name(resolveBody, "resolveBody");
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
makeRequest,
|
||||
resolveBody
|
||||
});
|
||||
//# sourceMappingURL=undiciRequest.js.map
|
1
node_modules/@discordjs/rest/dist/strategies/undiciRequest.js.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/dist/strategies/undiciRequest.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"sources":["../../src/strategies/undiciRequest.ts"],"sourcesContent":["import { STATUS_CODES } from 'node:http';\nimport { URLSearchParams } from 'node:url';\nimport { types } from 'node:util';\nimport { type RequestInit, request, Headers } from 'undici';\nimport type { ResponseLike } from '../shared.js';\n\nexport type RequestOptions = Exclude<Parameters<typeof request>[1], undefined>;\n\nexport async function makeRequest(url: string, init: RequestInit): Promise<ResponseLike> {\n\t// The cast is necessary because `headers` and `method` are narrower types in `undici.request`\n\t// our request path guarantees they are of acceptable type for `undici.request`\n\tconst options = {\n\t\t...init,\n\t\tbody: await resolveBody(init.body),\n\t} as RequestOptions;\n\tconst res = await request(url, options);\n\treturn {\n\t\tbody: res.body,\n\t\tasync arrayBuffer() {\n\t\t\treturn res.body.arrayBuffer();\n\t\t},\n\t\tasync json() {\n\t\t\treturn res.body.json();\n\t\t},\n\t\tasync text() {\n\t\t\treturn res.body.text();\n\t\t},\n\t\tget bodyUsed() {\n\t\t\treturn res.body.bodyUsed;\n\t\t},\n\t\theaders: new Headers(res.headers as Record<string, string[] | string>),\n\t\tstatus: res.statusCode,\n\t\tstatusText: STATUS_CODES[res.statusCode]!,\n\t\tok: res.statusCode >= 200 && res.statusCode < 300,\n\t};\n}\n\nexport async function resolveBody(body: RequestInit['body']): Promise<Exclude<RequestOptions['body'], undefined>> {\n\t// eslint-disable-next-line no-eq-null, eqeqeq\n\tif (body == null) {\n\t\treturn null;\n\t} else if (typeof body === 'string') {\n\t\treturn body;\n\t} else if (types.isUint8Array(body)) {\n\t\treturn body;\n\t} else if (types.isArrayBuffer(body)) {\n\t\treturn new Uint8Array(body);\n\t} else if (body instanceof URLSearchParams) {\n\t\treturn body.toString();\n\t} else if (body instanceof DataView) {\n\t\treturn new Uint8Array(body.buffer);\n\t} else if (body instanceof Blob) {\n\t\treturn new Uint8Array(await body.arrayBuffer());\n\t} else if (body instanceof FormData) {\n\t\treturn body;\n\t} else if ((body as Iterable<Uint8Array>)[Symbol.iterator]) {\n\t\tconst chunks = [...(body as Iterable<Uint8Array>)];\n\n\t\treturn Buffer.concat(chunks);\n\t} else if ((body as AsyncIterable<Uint8Array>)[Symbol.asyncIterator]) {\n\t\tconst chunks: Uint8Array[] = [];\n\n\t\tfor await (const chunk of body as AsyncIterable<Uint8Array>) {\n\t\t\tchunks.push(chunk);\n\t\t}\n\n\t\treturn Buffer.concat(chunks);\n\t}\n\n\tthrow new TypeError(`Unable to resolve body.`);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA6B;AAC7B,sBAAgC;AAChC,uBAAsB;AACtB,oBAAmD;AAKnD,eAAsB,YAAY,KAAa,MAA0C;AAGxF,QAAM,UAAU;AAAA,IACf,GAAG;AAAA,IACH,MAAM,MAAM,YAAY,KAAK,IAAI;AAAA,EAClC;AACA,QAAM,MAAM,UAAM,uBAAQ,KAAK,OAAO;AACtC,SAAO;AAAA,IACN,MAAM,IAAI;AAAA,IACV,MAAM,cAAc;AACnB,aAAO,IAAI,KAAK,YAAY;AAAA,IAC7B;AAAA,IACA,MAAM,OAAO;AACZ,aAAO,IAAI,KAAK,KAAK;AAAA,IACtB;AAAA,IACA,MAAM,OAAO;AACZ,aAAO,IAAI,KAAK,KAAK;AAAA,IACtB;AAAA,IACA,IAAI,WAAW;AACd,aAAO,IAAI,KAAK;AAAA,IACjB;AAAA,IACA,SAAS,IAAI,sBAAQ,IAAI,OAA4C;AAAA,IACrE,QAAQ,IAAI;AAAA,IACZ,YAAY,8BAAa,IAAI,UAAU;AAAA,IACvC,IAAI,IAAI,cAAc,OAAO,IAAI,aAAa;AAAA,EAC/C;AACD;AA3BsB;AA6BtB,eAAsB,YAAY,MAAgF;AAEjH,MAAI,QAAQ,MAAM;AACjB,WAAO;AAAA,EACR,WAAW,OAAO,SAAS,UAAU;AACpC,WAAO;AAAA,EACR,WAAW,uBAAM,aAAa,IAAI,GAAG;AACpC,WAAO;AAAA,EACR,WAAW,uBAAM,cAAc,IAAI,GAAG;AACrC,WAAO,IAAI,WAAW,IAAI;AAAA,EAC3B,WAAW,gBAAgB,iCAAiB;AAC3C,WAAO,KAAK,SAAS;AAAA,EACtB,WAAW,gBAAgB,UAAU;AACpC,WAAO,IAAI,WAAW,KAAK,MAAM;AAAA,EAClC,WAAW,gBAAgB,MAAM;AAChC,WAAO,IAAI,WAAW,MAAM,KAAK,YAAY,CAAC;AAAA,EAC/C,WAAW,gBAAgB,UAAU;AACpC,WAAO;AAAA,EACR,WAAY,KAA8B,OAAO,QAAQ,GAAG;AAC3D,UAAM,SAAS,CAAC,GAAI,IAA6B;AAEjD,WAAO,OAAO,OAAO,MAAM;AAAA,EAC5B,WAAY,KAAmC,OAAO,aAAa,GAAG;AACrE,UAAM,SAAuB,CAAC;AAE9B,qBAAiB,SAAS,MAAmC;AAC5D,aAAO,KAAK,KAAK;AAAA,IAClB;AAEA,WAAO,OAAO,OAAO,MAAM;AAAA,EAC5B;AAEA,QAAM,IAAI,UAAU,yBAAyB;AAC9C;AAjCsB;","names":[]}
|
70
node_modules/@discordjs/rest/dist/strategies/undiciRequest.mjs
generated
vendored
Normal file
70
node_modules/@discordjs/rest/dist/strategies/undiciRequest.mjs
generated
vendored
Normal file
|
@ -0,0 +1,70 @@
|
|||
var __defProp = Object.defineProperty;
|
||||
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
||||
|
||||
// src/strategies/undiciRequest.ts
|
||||
import { STATUS_CODES } from "node:http";
|
||||
import { URLSearchParams } from "node:url";
|
||||
import { types } from "node:util";
|
||||
import { request, Headers } from "undici";
|
||||
async function makeRequest(url, init) {
|
||||
const options = {
|
||||
...init,
|
||||
body: await resolveBody(init.body)
|
||||
};
|
||||
const res = await request(url, options);
|
||||
return {
|
||||
body: res.body,
|
||||
async arrayBuffer() {
|
||||
return res.body.arrayBuffer();
|
||||
},
|
||||
async json() {
|
||||
return res.body.json();
|
||||
},
|
||||
async text() {
|
||||
return res.body.text();
|
||||
},
|
||||
get bodyUsed() {
|
||||
return res.body.bodyUsed;
|
||||
},
|
||||
headers: new Headers(res.headers),
|
||||
status: res.statusCode,
|
||||
statusText: STATUS_CODES[res.statusCode],
|
||||
ok: res.statusCode >= 200 && res.statusCode < 300
|
||||
};
|
||||
}
|
||||
__name(makeRequest, "makeRequest");
|
||||
async function resolveBody(body) {
|
||||
if (body == null) {
|
||||
return null;
|
||||
} else if (typeof body === "string") {
|
||||
return body;
|
||||
} else if (types.isUint8Array(body)) {
|
||||
return body;
|
||||
} else if (types.isArrayBuffer(body)) {
|
||||
return new Uint8Array(body);
|
||||
} else if (body instanceof URLSearchParams) {
|
||||
return body.toString();
|
||||
} else if (body instanceof DataView) {
|
||||
return new Uint8Array(body.buffer);
|
||||
} else if (body instanceof Blob) {
|
||||
return new Uint8Array(await body.arrayBuffer());
|
||||
} else if (body instanceof FormData) {
|
||||
return body;
|
||||
} else if (body[Symbol.iterator]) {
|
||||
const chunks = [...body];
|
||||
return Buffer.concat(chunks);
|
||||
} else if (body[Symbol.asyncIterator]) {
|
||||
const chunks = [];
|
||||
for await (const chunk of body) {
|
||||
chunks.push(chunk);
|
||||
}
|
||||
return Buffer.concat(chunks);
|
||||
}
|
||||
throw new TypeError(`Unable to resolve body.`);
|
||||
}
|
||||
__name(resolveBody, "resolveBody");
|
||||
export {
|
||||
makeRequest,
|
||||
resolveBody
|
||||
};
|
||||
//# sourceMappingURL=undiciRequest.mjs.map
|
1
node_modules/@discordjs/rest/dist/strategies/undiciRequest.mjs.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/dist/strategies/undiciRequest.mjs.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"sources":["../../src/strategies/undiciRequest.ts"],"sourcesContent":["import { STATUS_CODES } from 'node:http';\nimport { URLSearchParams } from 'node:url';\nimport { types } from 'node:util';\nimport { type RequestInit, request, Headers } from 'undici';\nimport type { ResponseLike } from '../shared.js';\n\nexport type RequestOptions = Exclude<Parameters<typeof request>[1], undefined>;\n\nexport async function makeRequest(url: string, init: RequestInit): Promise<ResponseLike> {\n\t// The cast is necessary because `headers` and `method` are narrower types in `undici.request`\n\t// our request path guarantees they are of acceptable type for `undici.request`\n\tconst options = {\n\t\t...init,\n\t\tbody: await resolveBody(init.body),\n\t} as RequestOptions;\n\tconst res = await request(url, options);\n\treturn {\n\t\tbody: res.body,\n\t\tasync arrayBuffer() {\n\t\t\treturn res.body.arrayBuffer();\n\t\t},\n\t\tasync json() {\n\t\t\treturn res.body.json();\n\t\t},\n\t\tasync text() {\n\t\t\treturn res.body.text();\n\t\t},\n\t\tget bodyUsed() {\n\t\t\treturn res.body.bodyUsed;\n\t\t},\n\t\theaders: new Headers(res.headers as Record<string, string[] | string>),\n\t\tstatus: res.statusCode,\n\t\tstatusText: STATUS_CODES[res.statusCode]!,\n\t\tok: res.statusCode >= 200 && res.statusCode < 300,\n\t};\n}\n\nexport async function resolveBody(body: RequestInit['body']): Promise<Exclude<RequestOptions['body'], undefined>> {\n\t// eslint-disable-next-line no-eq-null, eqeqeq\n\tif (body == null) {\n\t\treturn null;\n\t} else if (typeof body === 'string') {\n\t\treturn body;\n\t} else if (types.isUint8Array(body)) {\n\t\treturn body;\n\t} else if (types.isArrayBuffer(body)) {\n\t\treturn new Uint8Array(body);\n\t} else if (body instanceof URLSearchParams) {\n\t\treturn body.toString();\n\t} else if (body instanceof DataView) {\n\t\treturn new Uint8Array(body.buffer);\n\t} else if (body instanceof Blob) {\n\t\treturn new Uint8Array(await body.arrayBuffer());\n\t} else if (body instanceof FormData) {\n\t\treturn body;\n\t} else if ((body as Iterable<Uint8Array>)[Symbol.iterator]) {\n\t\tconst chunks = [...(body as Iterable<Uint8Array>)];\n\n\t\treturn Buffer.concat(chunks);\n\t} else if ((body as AsyncIterable<Uint8Array>)[Symbol.asyncIterator]) {\n\t\tconst chunks: Uint8Array[] = [];\n\n\t\tfor await (const chunk of body as AsyncIterable<Uint8Array>) {\n\t\t\tchunks.push(chunk);\n\t\t}\n\n\t\treturn Buffer.concat(chunks);\n\t}\n\n\tthrow new TypeError(`Unable to resolve body.`);\n}\n"],"mappings":";;;;AAAA,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,SAAS,aAAa;AACtB,SAA2B,SAAS,eAAe;AAKnD,eAAsB,YAAY,KAAa,MAA0C;AAGxF,QAAM,UAAU;AAAA,IACf,GAAG;AAAA,IACH,MAAM,MAAM,YAAY,KAAK,IAAI;AAAA,EAClC;AACA,QAAM,MAAM,MAAM,QAAQ,KAAK,OAAO;AACtC,SAAO;AAAA,IACN,MAAM,IAAI;AAAA,IACV,MAAM,cAAc;AACnB,aAAO,IAAI,KAAK,YAAY;AAAA,IAC7B;AAAA,IACA,MAAM,OAAO;AACZ,aAAO,IAAI,KAAK,KAAK;AAAA,IACtB;AAAA,IACA,MAAM,OAAO;AACZ,aAAO,IAAI,KAAK,KAAK;AAAA,IACtB;AAAA,IACA,IAAI,WAAW;AACd,aAAO,IAAI,KAAK;AAAA,IACjB;AAAA,IACA,SAAS,IAAI,QAAQ,IAAI,OAA4C;AAAA,IACrE,QAAQ,IAAI;AAAA,IACZ,YAAY,aAAa,IAAI,UAAU;AAAA,IACvC,IAAI,IAAI,cAAc,OAAO,IAAI,aAAa;AAAA,EAC/C;AACD;AA3BsB;AA6BtB,eAAsB,YAAY,MAAgF;AAEjH,MAAI,QAAQ,MAAM;AACjB,WAAO;AAAA,EACR,WAAW,OAAO,SAAS,UAAU;AACpC,WAAO;AAAA,EACR,WAAW,MAAM,aAAa,IAAI,GAAG;AACpC,WAAO;AAAA,EACR,WAAW,MAAM,cAAc,IAAI,GAAG;AACrC,WAAO,IAAI,WAAW,IAAI;AAAA,EAC3B,WAAW,gBAAgB,iBAAiB;AAC3C,WAAO,KAAK,SAAS;AAAA,EACtB,WAAW,gBAAgB,UAAU;AACpC,WAAO,IAAI,WAAW,KAAK,MAAM;AAAA,EAClC,WAAW,gBAAgB,MAAM;AAChC,WAAO,IAAI,WAAW,MAAM,KAAK,YAAY,CAAC;AAAA,EAC/C,WAAW,gBAAgB,UAAU;AACpC,WAAO;AAAA,EACR,WAAY,KAA8B,OAAO,QAAQ,GAAG;AAC3D,UAAM,SAAS,CAAC,GAAI,IAA6B;AAEjD,WAAO,OAAO,OAAO,MAAM;AAAA,EAC5B,WAAY,KAAmC,OAAO,aAAa,GAAG;AACrE,UAAM,SAAuB,CAAC;AAE9B,qBAAiB,SAAS,MAAmC;AAC5D,aAAO,KAAK,KAAK;AAAA,IAClB;AAEA,WAAO,OAAO,OAAO,MAAM;AAAA,EAC5B;AAEA,QAAM,IAAI,UAAU,yBAAyB;AAC9C;AAjCsB;","names":[]}
|
901
node_modules/@discordjs/rest/dist/web.d.mts
generated
vendored
Normal file
901
node_modules/@discordjs/rest/dist/web.d.mts
generated
vendored
Normal file
|
@ -0,0 +1,901 @@
|
|||
import * as url from 'url';
|
||||
import { Snowflake } from 'discord-api-types/v10';
|
||||
import { Readable } from 'node:stream';
|
||||
import { ReadableStream } from 'node:stream/web';
|
||||
import { Collection } from '@discordjs/collection';
|
||||
import { Awaitable } from '@discordjs/util';
|
||||
import * as undici from 'undici';
|
||||
import { RequestInit, Dispatcher, Response, BodyInit, Agent } from 'undici';
|
||||
import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
|
||||
|
||||
interface IHandler {
|
||||
/**
|
||||
* The unique id of the handler
|
||||
*/
|
||||
readonly id: string;
|
||||
/**
|
||||
* If the bucket is currently inactive (no pending requests)
|
||||
*/
|
||||
get inactive(): boolean;
|
||||
/**
|
||||
* Queues a request to be sent
|
||||
*
|
||||
* @param routeId - The generalized api route with literal ids for major parameters
|
||||
* @param url - The url to do the request on
|
||||
* @param options - All the information needed to make a request
|
||||
* @param requestData - Extra data from the user's request needed for errors and additional processing
|
||||
*/
|
||||
queueRequest(routeId: RouteData, url: string, options: RequestInit, requestData: HandlerRequestData): Promise<ResponseLike>;
|
||||
}
|
||||
|
||||
interface RestEvents {
|
||||
handlerSweep: [sweptHandlers: Collection<string, IHandler>];
|
||||
hashSweep: [sweptHashes: Collection<string, HashData>];
|
||||
invalidRequestWarning: [invalidRequestInfo: InvalidRequestWarningData];
|
||||
rateLimited: [rateLimitInfo: RateLimitData];
|
||||
response: [request: APIRequest, response: ResponseLike];
|
||||
restDebug: [info: string];
|
||||
}
|
||||
type RestEventsMap = {
|
||||
[K in keyof RestEvents]: RestEvents[K];
|
||||
};
|
||||
/**
|
||||
* Options to be passed when creating the REST instance
|
||||
*/
|
||||
interface RESTOptions {
|
||||
/**
|
||||
* The agent to set globally
|
||||
*/
|
||||
agent: Dispatcher | null;
|
||||
/**
|
||||
* The base api path, without version
|
||||
*
|
||||
* @defaultValue `'https://discord.com/api'`
|
||||
*/
|
||||
api: string;
|
||||
/**
|
||||
* The authorization prefix to use for requests, useful if you want to use
|
||||
* bearer tokens
|
||||
*
|
||||
* @defaultValue `'Bot'`
|
||||
*/
|
||||
authPrefix: 'Bearer' | 'Bot';
|
||||
/**
|
||||
* The cdn path
|
||||
*
|
||||
* @defaultValue `'https://cdn.discordapp.com'`
|
||||
*/
|
||||
cdn: string;
|
||||
/**
|
||||
* How many requests to allow sending per second (Infinity for unlimited, 50 for the standard global limit used by Discord)
|
||||
*
|
||||
* @defaultValue `50`
|
||||
*/
|
||||
globalRequestsPerSecond: number;
|
||||
/**
|
||||
* The amount of time in milliseconds that passes between each hash sweep. (defaults to 1h)
|
||||
*
|
||||
* @defaultValue `3_600_000`
|
||||
*/
|
||||
handlerSweepInterval: number;
|
||||
/**
|
||||
* The maximum amount of time a hash can exist in milliseconds without being hit with a request (defaults to 24h)
|
||||
*
|
||||
* @defaultValue `86_400_000`
|
||||
*/
|
||||
hashLifetime: number;
|
||||
/**
|
||||
* The amount of time in milliseconds that passes between each hash sweep. (defaults to 4h)
|
||||
*
|
||||
* @defaultValue `14_400_000`
|
||||
*/
|
||||
hashSweepInterval: number;
|
||||
/**
|
||||
* Additional headers to send for all API requests
|
||||
*
|
||||
* @defaultValue `{}`
|
||||
*/
|
||||
headers: Record<string, string>;
|
||||
/**
|
||||
* The number of invalid REST requests (those that return 401, 403, or 429) in a 10 minute window between emitted warnings (0 for no warnings).
|
||||
* That is, if set to 500, warnings will be emitted at invalid request number 500, 1000, 1500, and so on.
|
||||
*
|
||||
* @defaultValue `0`
|
||||
*/
|
||||
invalidRequestWarningInterval: number;
|
||||
/**
|
||||
* The method called to perform the actual HTTP request given a url and web `fetch` options
|
||||
* For example, to use global fetch, simply provide `makeRequest: fetch`
|
||||
*/
|
||||
makeRequest(url: string, init: RequestInit): Promise<ResponseLike>;
|
||||
/**
|
||||
* The extra offset to add to rate limits in milliseconds
|
||||
*
|
||||
* @defaultValue `50`
|
||||
*/
|
||||
offset: number;
|
||||
/**
|
||||
* Determines how rate limiting and pre-emptive throttling should be handled.
|
||||
* When an array of strings, each element is treated as a prefix for the request route
|
||||
* (e.g. `/channels` to match any route starting with `/channels` such as `/channels/:id/messages`)
|
||||
* for which to throw {@link RateLimitError}s. All other request routes will be queued normally
|
||||
*
|
||||
* @defaultValue `null`
|
||||
*/
|
||||
rejectOnRateLimit: RateLimitQueueFilter | string[] | null;
|
||||
/**
|
||||
* The number of retries for errors with the 500 code, or errors
|
||||
* that timeout
|
||||
*
|
||||
* @defaultValue `3`
|
||||
*/
|
||||
retries: number;
|
||||
/**
|
||||
* The time to wait in milliseconds before a request is aborted
|
||||
*
|
||||
* @defaultValue `15_000`
|
||||
*/
|
||||
timeout: number;
|
||||
/**
|
||||
* Extra information to add to the user agent
|
||||
*
|
||||
* @defaultValue DefaultUserAgentAppendix
|
||||
*/
|
||||
userAgentAppendix: string;
|
||||
/**
|
||||
* The version of the API to use
|
||||
*
|
||||
* @defaultValue `'10'`
|
||||
*/
|
||||
version: string;
|
||||
}
|
||||
/**
|
||||
* Data emitted on `RESTEvents.RateLimited`
|
||||
*/
|
||||
interface RateLimitData {
|
||||
/**
|
||||
* Whether the rate limit that was reached was the global limit
|
||||
*/
|
||||
global: boolean;
|
||||
/**
|
||||
* The bucket hash for this request
|
||||
*/
|
||||
hash: string;
|
||||
/**
|
||||
* The amount of requests we can perform before locking requests
|
||||
*/
|
||||
limit: number;
|
||||
/**
|
||||
* The major parameter of the route
|
||||
*
|
||||
* For example, in `/channels/x`, this will be `x`.
|
||||
* If there is no major parameter (e.g: `/bot/gateway`) this will be `global`.
|
||||
*/
|
||||
majorParameter: string;
|
||||
/**
|
||||
* The HTTP method being performed
|
||||
*/
|
||||
method: string;
|
||||
/**
|
||||
* The time, in milliseconds, that will need to pass before this specific request can be retried
|
||||
*/
|
||||
retryAfter: number;
|
||||
/**
|
||||
* The route being hit in this request
|
||||
*/
|
||||
route: string;
|
||||
/**
|
||||
* The scope of the rate limit that was hit.
|
||||
*
|
||||
* This can be `user` for rate limits that are per client, `global` for rate limits that affect all clients or `shared` for rate limits that
|
||||
* are shared per resource.
|
||||
*/
|
||||
scope: 'global' | 'shared' | 'user';
|
||||
/**
|
||||
* The time, in milliseconds, that will need to pass before the sublimit lock for the route resets, and requests that fall under a sublimit
|
||||
* can be retried
|
||||
*
|
||||
* This is only present on certain sublimits, and `0` otherwise
|
||||
*/
|
||||
sublimitTimeout: number;
|
||||
/**
|
||||
* The time, in milliseconds, until the route's request-lock is reset
|
||||
*/
|
||||
timeToReset: number;
|
||||
/**
|
||||
* The full URL for this request
|
||||
*/
|
||||
url: string;
|
||||
}
|
||||
/**
|
||||
* A function that determines whether the rate limit hit should throw an Error
|
||||
*/
|
||||
type RateLimitQueueFilter = (rateLimitData: RateLimitData) => Awaitable<boolean>;
|
||||
interface APIRequest {
|
||||
/**
|
||||
* The data that was used to form the body of this request
|
||||
*/
|
||||
data: HandlerRequestData;
|
||||
/**
|
||||
* The HTTP method used in this request
|
||||
*/
|
||||
method: string;
|
||||
/**
|
||||
* Additional HTTP options for this request
|
||||
*/
|
||||
options: RequestInit;
|
||||
/**
|
||||
* The full path used to make the request
|
||||
*/
|
||||
path: RouteLike;
|
||||
/**
|
||||
* The number of times this request has been attempted
|
||||
*/
|
||||
retries: number;
|
||||
/**
|
||||
* The API route identifying the ratelimit for this request
|
||||
*/
|
||||
route: string;
|
||||
}
|
||||
interface ResponseLike extends Pick<Response, 'arrayBuffer' | 'bodyUsed' | 'headers' | 'json' | 'ok' | 'status' | 'statusText' | 'text'> {
|
||||
body: Readable | ReadableStream | null;
|
||||
}
|
||||
interface InvalidRequestWarningData {
|
||||
/**
|
||||
* Number of invalid requests that have been made in the window
|
||||
*/
|
||||
count: number;
|
||||
/**
|
||||
* Time in milliseconds remaining before the count resets
|
||||
*/
|
||||
remainingTime: number;
|
||||
}
|
||||
/**
|
||||
* Represents a file to be added to the request
|
||||
*/
|
||||
interface RawFile {
|
||||
/**
|
||||
* Content-Type of the file
|
||||
*/
|
||||
contentType?: string;
|
||||
/**
|
||||
* The actual data for the file
|
||||
*/
|
||||
data: Buffer | Uint8Array | boolean | number | string;
|
||||
/**
|
||||
* An explicit key to use for key of the formdata field for this file.
|
||||
* When not provided, the index of the file in the files array is used in the form `files[${index}]`.
|
||||
* If you wish to alter the placeholder snowflake, you must provide this property in the same form (`files[${placeholder}]`)
|
||||
*/
|
||||
key?: string;
|
||||
/**
|
||||
* The name of the file
|
||||
*/
|
||||
name: string;
|
||||
}
|
||||
/**
|
||||
* Represents possible data to be given to an endpoint
|
||||
*/
|
||||
interface RequestData {
|
||||
/**
|
||||
* Whether to append JSON data to form data instead of `payload_json` when sending files
|
||||
*/
|
||||
appendToFormData?: boolean;
|
||||
/**
|
||||
* If this request needs the `Authorization` header
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
auth?: boolean;
|
||||
/**
|
||||
* The authorization prefix to use for this request, useful if you use this with bearer tokens
|
||||
*
|
||||
* @defaultValue `'Bot'`
|
||||
*/
|
||||
authPrefix?: 'Bearer' | 'Bot';
|
||||
/**
|
||||
* The body to send to this request.
|
||||
* If providing as BodyInit, set `passThroughBody: true`
|
||||
*/
|
||||
body?: BodyInit | unknown;
|
||||
/**
|
||||
* The {@link https://undici.nodejs.org/#/docs/api/Agent | Agent} to use for the request.
|
||||
*/
|
||||
dispatcher?: Agent;
|
||||
/**
|
||||
* Files to be attached to this request
|
||||
*/
|
||||
files?: RawFile[] | undefined;
|
||||
/**
|
||||
* Additional headers to add to this request
|
||||
*/
|
||||
headers?: Record<string, string>;
|
||||
/**
|
||||
* Whether to pass-through the body property directly to `fetch()`.
|
||||
* <warn>This only applies when files is NOT present</warn>
|
||||
*/
|
||||
passThroughBody?: boolean;
|
||||
/**
|
||||
* Query string parameters to append to the called endpoint
|
||||
*/
|
||||
query?: URLSearchParams;
|
||||
/**
|
||||
* Reason to show in the audit logs
|
||||
*/
|
||||
reason?: string | undefined;
|
||||
/**
|
||||
* The signal to abort the queue entry or the REST call, where applicable
|
||||
*/
|
||||
signal?: AbortSignal | undefined;
|
||||
/**
|
||||
* If this request should be versioned
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
versioned?: boolean;
|
||||
}
|
||||
/**
|
||||
* Possible headers for an API call
|
||||
*/
|
||||
interface RequestHeaders {
|
||||
Authorization?: string;
|
||||
'User-Agent': string;
|
||||
'X-Audit-Log-Reason'?: string;
|
||||
}
|
||||
/**
|
||||
* Possible API methods to be used when doing requests
|
||||
*/
|
||||
declare enum RequestMethod {
|
||||
Delete = "DELETE",
|
||||
Get = "GET",
|
||||
Patch = "PATCH",
|
||||
Post = "POST",
|
||||
Put = "PUT"
|
||||
}
|
||||
type RouteLike = `/${string}`;
|
||||
/**
|
||||
* Internal request options
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface InternalRequest extends RequestData {
|
||||
fullRoute: RouteLike;
|
||||
method: RequestMethod;
|
||||
}
|
||||
type HandlerRequestData = Pick<InternalRequest, 'auth' | 'body' | 'files' | 'signal'>;
|
||||
/**
|
||||
* Parsed route data for an endpoint
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface RouteData {
|
||||
bucketRoute: string;
|
||||
majorParameter: string;
|
||||
original: RouteLike;
|
||||
}
|
||||
/**
|
||||
* Represents a hash and its associated fields
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface HashData {
|
||||
lastAccess: number;
|
||||
value: string;
|
||||
}
|
||||
|
||||
declare const DefaultUserAgent: `DiscordBot (https://discord.js.org, ${string})`;
|
||||
/**
|
||||
* The default string to append onto the user agent.
|
||||
*/
|
||||
declare const DefaultUserAgentAppendix: string;
|
||||
declare const DefaultRestOptions: {
|
||||
readonly agent: null;
|
||||
readonly api: "https://discord.com/api";
|
||||
readonly authPrefix: "Bot";
|
||||
readonly cdn: "https://cdn.discordapp.com";
|
||||
readonly headers: {};
|
||||
readonly invalidRequestWarningInterval: 0;
|
||||
readonly globalRequestsPerSecond: 50;
|
||||
readonly offset: 50;
|
||||
readonly rejectOnRateLimit: null;
|
||||
readonly retries: 3;
|
||||
readonly timeout: 15000;
|
||||
readonly userAgentAppendix: string;
|
||||
readonly version: "10";
|
||||
readonly hashSweepInterval: 14400000;
|
||||
readonly hashLifetime: 86400000;
|
||||
readonly handlerSweepInterval: 3600000;
|
||||
readonly makeRequest: (url: string, init: undici.RequestInit) => Promise<ResponseLike>;
|
||||
};
|
||||
/**
|
||||
* The events that the REST manager emits
|
||||
*/
|
||||
declare enum RESTEvents {
|
||||
Debug = "restDebug",
|
||||
HandlerSweep = "handlerSweep",
|
||||
HashSweep = "hashSweep",
|
||||
InvalidRequestWarning = "invalidRequestWarning",
|
||||
RateLimited = "rateLimited",
|
||||
Response = "response"
|
||||
}
|
||||
declare const ALLOWED_EXTENSIONS: readonly ["webp", "png", "jpg", "jpeg", "gif"];
|
||||
declare const ALLOWED_STICKER_EXTENSIONS: readonly ["png", "json", "gif"];
|
||||
declare const ALLOWED_SIZES: readonly [16, 32, 64, 128, 256, 512, 1024, 2048, 4096];
|
||||
type ImageExtension = (typeof ALLOWED_EXTENSIONS)[number];
|
||||
type StickerExtension = (typeof ALLOWED_STICKER_EXTENSIONS)[number];
|
||||
type ImageSize = (typeof ALLOWED_SIZES)[number];
|
||||
declare const OverwrittenMimeTypes: {
|
||||
readonly 'image/apng': "image/png";
|
||||
};
|
||||
declare const BurstHandlerMajorIdKey = "burst";
|
||||
/**
|
||||
* Prefix for deprecation warnings.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
declare const DEPRECATION_WARNING_PREFIX: "DeprecationWarning";
|
||||
|
||||
/**
|
||||
* The options used for image URLs
|
||||
*/
|
||||
interface BaseImageURLOptions {
|
||||
/**
|
||||
* The extension to use for the image URL
|
||||
*
|
||||
* @defaultValue `'webp'`
|
||||
*/
|
||||
extension?: ImageExtension;
|
||||
/**
|
||||
* The size specified in the image URL
|
||||
*/
|
||||
size?: ImageSize;
|
||||
}
|
||||
/**
|
||||
* The options used for image URLs with animated content
|
||||
*/
|
||||
interface ImageURLOptions extends BaseImageURLOptions {
|
||||
/**
|
||||
* Whether or not to prefer the static version of an image asset.
|
||||
*/
|
||||
forceStatic?: boolean;
|
||||
}
|
||||
/**
|
||||
* The options to use when making a CDN URL
|
||||
*/
|
||||
interface MakeURLOptions {
|
||||
/**
|
||||
* The allowed extensions that can be used
|
||||
*/
|
||||
allowedExtensions?: readonly string[];
|
||||
/**
|
||||
* The extension to use for the image URL
|
||||
*
|
||||
* @defaultValue `'webp'`
|
||||
*/
|
||||
extension?: string | undefined;
|
||||
/**
|
||||
* The size specified in the image URL
|
||||
*/
|
||||
size?: ImageSize;
|
||||
}
|
||||
/**
|
||||
* The CDN link builder
|
||||
*/
|
||||
declare class CDN {
|
||||
private readonly base;
|
||||
constructor(base?: string);
|
||||
/**
|
||||
* Generates an app asset URL for a client's asset.
|
||||
*
|
||||
* @param clientId - The client id that has the asset
|
||||
* @param assetHash - The hash provided by Discord for this asset
|
||||
* @param options - Optional options for the asset
|
||||
*/
|
||||
appAsset(clientId: string, assetHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates an app icon URL for a client's icon.
|
||||
*
|
||||
* @param clientId - The client id that has the icon
|
||||
* @param iconHash - The hash provided by Discord for this icon
|
||||
* @param options - Optional options for the icon
|
||||
*/
|
||||
appIcon(clientId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates an avatar URL, e.g. for a user or a webhook.
|
||||
*
|
||||
* @param id - The id that has the icon
|
||||
* @param avatarHash - The hash provided by Discord for this avatar
|
||||
* @param options - Optional options for the avatar
|
||||
*/
|
||||
avatar(id: string, avatarHash: string, options?: Readonly<ImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a user avatar decoration URL.
|
||||
*
|
||||
* @param userId - The id of the user
|
||||
* @param userAvatarDecoration - The hash provided by Discord for this avatar decoration
|
||||
* @param options - Optional options for the avatar decoration
|
||||
*/
|
||||
avatarDecoration(userId: string, userAvatarDecoration: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a banner URL, e.g. for a user or a guild.
|
||||
*
|
||||
* @param id - The id that has the banner splash
|
||||
* @param bannerHash - The hash provided by Discord for this banner
|
||||
* @param options - Optional options for the banner
|
||||
*/
|
||||
banner(id: string, bannerHash: string, options?: Readonly<ImageURLOptions>): string;
|
||||
/**
|
||||
* Generates an icon URL for a channel, e.g. a group DM.
|
||||
*
|
||||
* @param channelId - The channel id that has the icon
|
||||
* @param iconHash - The hash provided by Discord for this channel
|
||||
* @param options - Optional options for the icon
|
||||
*/
|
||||
channelIcon(channelId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a default avatar URL
|
||||
*
|
||||
* @param index - The default avatar index
|
||||
* @remarks
|
||||
* To calculate the index for a user do `(userId >> 22) % 6`,
|
||||
* or `discriminator % 5` if they're using the legacy username system.
|
||||
*/
|
||||
defaultAvatar(index: number): string;
|
||||
/**
|
||||
* Generates a discovery splash URL for a guild's discovery splash.
|
||||
*
|
||||
* @param guildId - The guild id that has the discovery splash
|
||||
* @param splashHash - The hash provided by Discord for this splash
|
||||
* @param options - Optional options for the splash
|
||||
*/
|
||||
discoverySplash(guildId: string, splashHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates an emoji's URL for an emoji.
|
||||
*
|
||||
* @param emojiId - The emoji id
|
||||
* @param options - Optional options for the emoji
|
||||
*/
|
||||
emoji(emojiId: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates an emoji's URL for an emoji.
|
||||
*
|
||||
* @param emojiId - The emoji id
|
||||
* @param extension - The extension of the emoji
|
||||
* @deprecated This overload is deprecated. Pass an object containing the extension instead.
|
||||
*/
|
||||
emoji(emojiId: string, extension?: ImageExtension): string;
|
||||
/**
|
||||
* Generates a guild member avatar URL.
|
||||
*
|
||||
* @param guildId - The id of the guild
|
||||
* @param userId - The id of the user
|
||||
* @param avatarHash - The hash provided by Discord for this avatar
|
||||
* @param options - Optional options for the avatar
|
||||
*/
|
||||
guildMemberAvatar(guildId: string, userId: string, avatarHash: string, options?: Readonly<ImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a guild member banner URL.
|
||||
*
|
||||
* @param guildId - The id of the guild
|
||||
* @param userId - The id of the user
|
||||
* @param bannerHash - The hash provided by Discord for this banner
|
||||
* @param options - Optional options for the banner
|
||||
*/
|
||||
guildMemberBanner(guildId: string, userId: string, bannerHash: string, options?: Readonly<ImageURLOptions>): string;
|
||||
/**
|
||||
* Generates an icon URL, e.g. for a guild.
|
||||
*
|
||||
* @param id - The id that has the icon splash
|
||||
* @param iconHash - The hash provided by Discord for this icon
|
||||
* @param options - Optional options for the icon
|
||||
*/
|
||||
icon(id: string, iconHash: string, options?: Readonly<ImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a URL for the icon of a role
|
||||
*
|
||||
* @param roleId - The id of the role that has the icon
|
||||
* @param roleIconHash - The hash provided by Discord for this role icon
|
||||
* @param options - Optional options for the role icon
|
||||
*/
|
||||
roleIcon(roleId: string, roleIconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a guild invite splash URL for a guild's invite splash.
|
||||
*
|
||||
* @param guildId - The guild id that has the invite splash
|
||||
* @param splashHash - The hash provided by Discord for this splash
|
||||
* @param options - Optional options for the splash
|
||||
*/
|
||||
splash(guildId: string, splashHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a sticker URL.
|
||||
*
|
||||
* @param stickerId - The sticker id
|
||||
* @param extension - The extension of the sticker
|
||||
* @privateRemarks
|
||||
* Stickers cannot have a `.webp` extension, so we default to a `.png`
|
||||
*/
|
||||
sticker(stickerId: string, extension?: StickerExtension): string;
|
||||
/**
|
||||
* Generates a sticker pack banner URL.
|
||||
*
|
||||
* @param bannerId - The banner id
|
||||
* @param options - Optional options for the banner
|
||||
*/
|
||||
stickerPackBanner(bannerId: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a team icon URL for a team's icon.
|
||||
*
|
||||
* @param teamId - The team id that has the icon
|
||||
* @param iconHash - The hash provided by Discord for this icon
|
||||
* @param options - Optional options for the icon
|
||||
*/
|
||||
teamIcon(teamId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a cover image for a guild scheduled event.
|
||||
*
|
||||
* @param scheduledEventId - The scheduled event id
|
||||
* @param coverHash - The hash provided by discord for this cover image
|
||||
* @param options - Optional options for the cover image
|
||||
*/
|
||||
guildScheduledEventCover(scheduledEventId: string, coverHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Constructs the URL for the resource, checking whether or not `hash` starts with `a_` if `dynamic` is set to `true`.
|
||||
*
|
||||
* @param route - The base cdn route
|
||||
* @param hash - The hash provided by Discord for this icon
|
||||
* @param options - Optional options for the link
|
||||
*/
|
||||
private dynamicMakeURL;
|
||||
/**
|
||||
* Constructs the URL for the resource
|
||||
*
|
||||
* @param route - The base cdn route
|
||||
* @param options - The extension/size options for the link
|
||||
*/
|
||||
private makeURL;
|
||||
}
|
||||
|
||||
interface DiscordErrorFieldInformation {
|
||||
code: string;
|
||||
message: string;
|
||||
}
|
||||
interface DiscordErrorGroupWrapper {
|
||||
_errors: DiscordError[];
|
||||
}
|
||||
type DiscordError = DiscordErrorFieldInformation | DiscordErrorGroupWrapper | string | {
|
||||
[k: string]: DiscordError;
|
||||
};
|
||||
interface DiscordErrorData {
|
||||
code: number;
|
||||
errors?: DiscordError;
|
||||
message: string;
|
||||
}
|
||||
interface OAuthErrorData {
|
||||
error: string;
|
||||
error_description?: string;
|
||||
}
|
||||
interface RequestBody {
|
||||
files: RawFile[] | undefined;
|
||||
json: unknown | undefined;
|
||||
}
|
||||
/**
|
||||
* Represents an API error returned by Discord
|
||||
*/
|
||||
declare class DiscordAPIError extends Error {
|
||||
rawError: DiscordErrorData | OAuthErrorData;
|
||||
code: number | string;
|
||||
status: number;
|
||||
method: string;
|
||||
url: string;
|
||||
requestBody: RequestBody;
|
||||
/**
|
||||
* @param rawError - The error reported by Discord
|
||||
* @param code - The error code reported by Discord
|
||||
* @param status - The status code of the response
|
||||
* @param method - The method of the request that erred
|
||||
* @param url - The url of the request that erred
|
||||
* @param bodyData - The unparsed data for the request that errored
|
||||
*/
|
||||
constructor(rawError: DiscordErrorData | OAuthErrorData, code: number | string, status: number, method: string, url: string, bodyData: Pick<InternalRequest, 'body' | 'files'>);
|
||||
/**
|
||||
* The name of the error
|
||||
*/
|
||||
get name(): string;
|
||||
private static getMessage;
|
||||
private static flattenDiscordError;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a HTTP error
|
||||
*/
|
||||
declare class HTTPError extends Error {
|
||||
status: number;
|
||||
method: string;
|
||||
url: string;
|
||||
requestBody: RequestBody;
|
||||
name: string;
|
||||
/**
|
||||
* @param status - The status code of the response
|
||||
* @param statusText - The status text of the response
|
||||
* @param method - The method of the request that erred
|
||||
* @param url - The url of the request that erred
|
||||
* @param bodyData - The unparsed data for the request that errored
|
||||
*/
|
||||
constructor(status: number, statusText: string, method: string, url: string, bodyData: Pick<InternalRequest, 'body' | 'files'>);
|
||||
}
|
||||
|
||||
declare class RateLimitError extends Error implements RateLimitData {
|
||||
timeToReset: number;
|
||||
limit: number;
|
||||
method: string;
|
||||
hash: string;
|
||||
url: string;
|
||||
route: string;
|
||||
majorParameter: string;
|
||||
global: boolean;
|
||||
retryAfter: number;
|
||||
sublimitTimeout: number;
|
||||
scope: RateLimitData['scope'];
|
||||
constructor({ timeToReset, limit, method, hash, url, route, majorParameter, global, retryAfter, sublimitTimeout, scope, }: RateLimitData);
|
||||
/**
|
||||
* The name of the error
|
||||
*/
|
||||
get name(): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the class that manages handlers for endpoints
|
||||
*/
|
||||
declare class REST extends AsyncEventEmitter<RestEventsMap> {
|
||||
#private;
|
||||
/**
|
||||
* The {@link https://undici.nodejs.org/#/docs/api/Agent | Agent} for all requests
|
||||
* performed by this manager.
|
||||
*/
|
||||
agent: Dispatcher | null;
|
||||
readonly cdn: CDN;
|
||||
/**
|
||||
* The number of requests remaining in the global bucket
|
||||
*/
|
||||
globalRemaining: number;
|
||||
/**
|
||||
* The promise used to wait out the global rate limit
|
||||
*/
|
||||
globalDelay: Promise<void> | null;
|
||||
/**
|
||||
* The timestamp at which the global bucket resets
|
||||
*/
|
||||
globalReset: number;
|
||||
/**
|
||||
* API bucket hashes that are cached from provided routes
|
||||
*/
|
||||
readonly hashes: Collection<string, HashData>;
|
||||
/**
|
||||
* Request handlers created from the bucket hash and the major parameters
|
||||
*/
|
||||
readonly handlers: Collection<string, IHandler>;
|
||||
private hashTimer;
|
||||
private handlerTimer;
|
||||
readonly options: RESTOptions;
|
||||
constructor(options?: Partial<RESTOptions>);
|
||||
private setupSweepers;
|
||||
/**
|
||||
* Runs a get request from the api
|
||||
*
|
||||
* @param fullRoute - The full route to query
|
||||
* @param options - Optional request options
|
||||
*/
|
||||
get(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||
/**
|
||||
* Runs a delete request from the api
|
||||
*
|
||||
* @param fullRoute - The full route to query
|
||||
* @param options - Optional request options
|
||||
*/
|
||||
delete(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||
/**
|
||||
* Runs a post request from the api
|
||||
*
|
||||
* @param fullRoute - The full route to query
|
||||
* @param options - Optional request options
|
||||
*/
|
||||
post(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||
/**
|
||||
* Runs a put request from the api
|
||||
*
|
||||
* @param fullRoute - The full route to query
|
||||
* @param options - Optional request options
|
||||
*/
|
||||
put(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||
/**
|
||||
* Runs a patch request from the api
|
||||
*
|
||||
* @param fullRoute - The full route to query
|
||||
* @param options - Optional request options
|
||||
*/
|
||||
patch(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||
/**
|
||||
* Runs a request from the api
|
||||
*
|
||||
* @param options - Request options
|
||||
*/
|
||||
request(options: InternalRequest): Promise<unknown>;
|
||||
/**
|
||||
* Sets the default agent to use for requests performed by this manager
|
||||
*
|
||||
* @param agent - The agent to use
|
||||
*/
|
||||
setAgent(agent: Dispatcher): this;
|
||||
/**
|
||||
* Sets the authorization token that should be used for requests
|
||||
*
|
||||
* @param token - The authorization token to use
|
||||
*/
|
||||
setToken(token: string): this;
|
||||
/**
|
||||
* Queues a request to be sent
|
||||
*
|
||||
* @param request - All the information needed to make a request
|
||||
* @returns The response from the api request
|
||||
*/
|
||||
queueRequest(request: InternalRequest): Promise<ResponseLike>;
|
||||
/**
|
||||
* Creates a new rate limit handler from a hash, based on the hash and the major parameter
|
||||
*
|
||||
* @param hash - The hash for the route
|
||||
* @param majorParameter - The major parameter for this handler
|
||||
* @internal
|
||||
*/
|
||||
private createHandler;
|
||||
/**
|
||||
* Formats the request data to a usable format for fetch
|
||||
*
|
||||
* @param request - The request data
|
||||
*/
|
||||
private resolveRequest;
|
||||
/**
|
||||
* Stops the hash sweeping interval
|
||||
*/
|
||||
clearHashSweeper(): void;
|
||||
/**
|
||||
* Stops the request handler sweeping interval
|
||||
*/
|
||||
clearHandlerSweeper(): void;
|
||||
/**
|
||||
* Generates route data for an endpoint:method
|
||||
*
|
||||
* @param endpoint - The raw endpoint to generalize
|
||||
* @param method - The HTTP method this endpoint is called without
|
||||
* @internal
|
||||
*/
|
||||
private static generateRouteData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and populates an URLSearchParams instance from an object, stripping
|
||||
* out null and undefined values, while also coercing non-strings to strings.
|
||||
*
|
||||
* @param options - The options to use
|
||||
* @returns A populated URLSearchParams instance
|
||||
*/
|
||||
declare function makeURLSearchParams<OptionsType extends object>(options?: Readonly<OptionsType>): url.URLSearchParams;
|
||||
/**
|
||||
* Converts the response to usable data
|
||||
*
|
||||
* @param res - The fetch response
|
||||
*/
|
||||
declare function parseResponse(res: ResponseLike): Promise<unknown>;
|
||||
/**
|
||||
* Calculates the default avatar index for a given user id.
|
||||
*
|
||||
* @param userId - The user id to calculate the default avatar index for
|
||||
*/
|
||||
declare function calculateUserDefaultAvatarIndex(userId: Snowflake): number;
|
||||
|
||||
/**
|
||||
* The {@link https://github.com/discordjs/discord.js/blob/main/packages/rest#readme | @discordjs/rest} version
|
||||
* that you are currently using.
|
||||
*/
|
||||
declare const version: string;
|
||||
|
||||
export { ALLOWED_EXTENSIONS, ALLOWED_SIZES, ALLOWED_STICKER_EXTENSIONS, APIRequest, BaseImageURLOptions, BurstHandlerMajorIdKey, CDN, DEPRECATION_WARNING_PREFIX, DefaultRestOptions, DefaultUserAgent, DefaultUserAgentAppendix, DiscordAPIError, DiscordErrorData, HTTPError, HandlerRequestData, HashData, ImageExtension, ImageSize, ImageURLOptions, InternalRequest, InvalidRequestWarningData, MakeURLOptions, OAuthErrorData, OverwrittenMimeTypes, REST, RESTEvents, RESTOptions, RateLimitData, RateLimitError, RateLimitQueueFilter, RawFile, RequestBody, RequestData, RequestHeaders, RequestMethod, ResponseLike, RestEvents, RestEventsMap, RouteData, RouteLike, StickerExtension, calculateUserDefaultAvatarIndex, makeURLSearchParams, parseResponse, version };
|
901
node_modules/@discordjs/rest/dist/web.d.ts
generated
vendored
Normal file
901
node_modules/@discordjs/rest/dist/web.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,901 @@
|
|||
import * as url from 'url';
|
||||
import { Snowflake } from 'discord-api-types/v10';
|
||||
import { Readable } from 'node:stream';
|
||||
import { ReadableStream } from 'node:stream/web';
|
||||
import { Collection } from '@discordjs/collection';
|
||||
import { Awaitable } from '@discordjs/util';
|
||||
import * as undici from 'undici';
|
||||
import { RequestInit, Dispatcher, Response, BodyInit, Agent } from 'undici';
|
||||
import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
|
||||
|
||||
interface IHandler {
|
||||
/**
|
||||
* The unique id of the handler
|
||||
*/
|
||||
readonly id: string;
|
||||
/**
|
||||
* If the bucket is currently inactive (no pending requests)
|
||||
*/
|
||||
get inactive(): boolean;
|
||||
/**
|
||||
* Queues a request to be sent
|
||||
*
|
||||
* @param routeId - The generalized api route with literal ids for major parameters
|
||||
* @param url - The url to do the request on
|
||||
* @param options - All the information needed to make a request
|
||||
* @param requestData - Extra data from the user's request needed for errors and additional processing
|
||||
*/
|
||||
queueRequest(routeId: RouteData, url: string, options: RequestInit, requestData: HandlerRequestData): Promise<ResponseLike>;
|
||||
}
|
||||
|
||||
interface RestEvents {
|
||||
handlerSweep: [sweptHandlers: Collection<string, IHandler>];
|
||||
hashSweep: [sweptHashes: Collection<string, HashData>];
|
||||
invalidRequestWarning: [invalidRequestInfo: InvalidRequestWarningData];
|
||||
rateLimited: [rateLimitInfo: RateLimitData];
|
||||
response: [request: APIRequest, response: ResponseLike];
|
||||
restDebug: [info: string];
|
||||
}
|
||||
type RestEventsMap = {
|
||||
[K in keyof RestEvents]: RestEvents[K];
|
||||
};
|
||||
/**
|
||||
* Options to be passed when creating the REST instance
|
||||
*/
|
||||
interface RESTOptions {
|
||||
/**
|
||||
* The agent to set globally
|
||||
*/
|
||||
agent: Dispatcher | null;
|
||||
/**
|
||||
* The base api path, without version
|
||||
*
|
||||
* @defaultValue `'https://discord.com/api'`
|
||||
*/
|
||||
api: string;
|
||||
/**
|
||||
* The authorization prefix to use for requests, useful if you want to use
|
||||
* bearer tokens
|
||||
*
|
||||
* @defaultValue `'Bot'`
|
||||
*/
|
||||
authPrefix: 'Bearer' | 'Bot';
|
||||
/**
|
||||
* The cdn path
|
||||
*
|
||||
* @defaultValue `'https://cdn.discordapp.com'`
|
||||
*/
|
||||
cdn: string;
|
||||
/**
|
||||
* How many requests to allow sending per second (Infinity for unlimited, 50 for the standard global limit used by Discord)
|
||||
*
|
||||
* @defaultValue `50`
|
||||
*/
|
||||
globalRequestsPerSecond: number;
|
||||
/**
|
||||
* The amount of time in milliseconds that passes between each hash sweep. (defaults to 1h)
|
||||
*
|
||||
* @defaultValue `3_600_000`
|
||||
*/
|
||||
handlerSweepInterval: number;
|
||||
/**
|
||||
* The maximum amount of time a hash can exist in milliseconds without being hit with a request (defaults to 24h)
|
||||
*
|
||||
* @defaultValue `86_400_000`
|
||||
*/
|
||||
hashLifetime: number;
|
||||
/**
|
||||
* The amount of time in milliseconds that passes between each hash sweep. (defaults to 4h)
|
||||
*
|
||||
* @defaultValue `14_400_000`
|
||||
*/
|
||||
hashSweepInterval: number;
|
||||
/**
|
||||
* Additional headers to send for all API requests
|
||||
*
|
||||
* @defaultValue `{}`
|
||||
*/
|
||||
headers: Record<string, string>;
|
||||
/**
|
||||
* The number of invalid REST requests (those that return 401, 403, or 429) in a 10 minute window between emitted warnings (0 for no warnings).
|
||||
* That is, if set to 500, warnings will be emitted at invalid request number 500, 1000, 1500, and so on.
|
||||
*
|
||||
* @defaultValue `0`
|
||||
*/
|
||||
invalidRequestWarningInterval: number;
|
||||
/**
|
||||
* The method called to perform the actual HTTP request given a url and web `fetch` options
|
||||
* For example, to use global fetch, simply provide `makeRequest: fetch`
|
||||
*/
|
||||
makeRequest(url: string, init: RequestInit): Promise<ResponseLike>;
|
||||
/**
|
||||
* The extra offset to add to rate limits in milliseconds
|
||||
*
|
||||
* @defaultValue `50`
|
||||
*/
|
||||
offset: number;
|
||||
/**
|
||||
* Determines how rate limiting and pre-emptive throttling should be handled.
|
||||
* When an array of strings, each element is treated as a prefix for the request route
|
||||
* (e.g. `/channels` to match any route starting with `/channels` such as `/channels/:id/messages`)
|
||||
* for which to throw {@link RateLimitError}s. All other request routes will be queued normally
|
||||
*
|
||||
* @defaultValue `null`
|
||||
*/
|
||||
rejectOnRateLimit: RateLimitQueueFilter | string[] | null;
|
||||
/**
|
||||
* The number of retries for errors with the 500 code, or errors
|
||||
* that timeout
|
||||
*
|
||||
* @defaultValue `3`
|
||||
*/
|
||||
retries: number;
|
||||
/**
|
||||
* The time to wait in milliseconds before a request is aborted
|
||||
*
|
||||
* @defaultValue `15_000`
|
||||
*/
|
||||
timeout: number;
|
||||
/**
|
||||
* Extra information to add to the user agent
|
||||
*
|
||||
* @defaultValue DefaultUserAgentAppendix
|
||||
*/
|
||||
userAgentAppendix: string;
|
||||
/**
|
||||
* The version of the API to use
|
||||
*
|
||||
* @defaultValue `'10'`
|
||||
*/
|
||||
version: string;
|
||||
}
|
||||
/**
|
||||
* Data emitted on `RESTEvents.RateLimited`
|
||||
*/
|
||||
interface RateLimitData {
|
||||
/**
|
||||
* Whether the rate limit that was reached was the global limit
|
||||
*/
|
||||
global: boolean;
|
||||
/**
|
||||
* The bucket hash for this request
|
||||
*/
|
||||
hash: string;
|
||||
/**
|
||||
* The amount of requests we can perform before locking requests
|
||||
*/
|
||||
limit: number;
|
||||
/**
|
||||
* The major parameter of the route
|
||||
*
|
||||
* For example, in `/channels/x`, this will be `x`.
|
||||
* If there is no major parameter (e.g: `/bot/gateway`) this will be `global`.
|
||||
*/
|
||||
majorParameter: string;
|
||||
/**
|
||||
* The HTTP method being performed
|
||||
*/
|
||||
method: string;
|
||||
/**
|
||||
* The time, in milliseconds, that will need to pass before this specific request can be retried
|
||||
*/
|
||||
retryAfter: number;
|
||||
/**
|
||||
* The route being hit in this request
|
||||
*/
|
||||
route: string;
|
||||
/**
|
||||
* The scope of the rate limit that was hit.
|
||||
*
|
||||
* This can be `user` for rate limits that are per client, `global` for rate limits that affect all clients or `shared` for rate limits that
|
||||
* are shared per resource.
|
||||
*/
|
||||
scope: 'global' | 'shared' | 'user';
|
||||
/**
|
||||
* The time, in milliseconds, that will need to pass before the sublimit lock for the route resets, and requests that fall under a sublimit
|
||||
* can be retried
|
||||
*
|
||||
* This is only present on certain sublimits, and `0` otherwise
|
||||
*/
|
||||
sublimitTimeout: number;
|
||||
/**
|
||||
* The time, in milliseconds, until the route's request-lock is reset
|
||||
*/
|
||||
timeToReset: number;
|
||||
/**
|
||||
* The full URL for this request
|
||||
*/
|
||||
url: string;
|
||||
}
|
||||
/**
|
||||
* A function that determines whether the rate limit hit should throw an Error
|
||||
*/
|
||||
type RateLimitQueueFilter = (rateLimitData: RateLimitData) => Awaitable<boolean>;
|
||||
interface APIRequest {
|
||||
/**
|
||||
* The data that was used to form the body of this request
|
||||
*/
|
||||
data: HandlerRequestData;
|
||||
/**
|
||||
* The HTTP method used in this request
|
||||
*/
|
||||
method: string;
|
||||
/**
|
||||
* Additional HTTP options for this request
|
||||
*/
|
||||
options: RequestInit;
|
||||
/**
|
||||
* The full path used to make the request
|
||||
*/
|
||||
path: RouteLike;
|
||||
/**
|
||||
* The number of times this request has been attempted
|
||||
*/
|
||||
retries: number;
|
||||
/**
|
||||
* The API route identifying the ratelimit for this request
|
||||
*/
|
||||
route: string;
|
||||
}
|
||||
interface ResponseLike extends Pick<Response, 'arrayBuffer' | 'bodyUsed' | 'headers' | 'json' | 'ok' | 'status' | 'statusText' | 'text'> {
|
||||
body: Readable | ReadableStream | null;
|
||||
}
|
||||
interface InvalidRequestWarningData {
|
||||
/**
|
||||
* Number of invalid requests that have been made in the window
|
||||
*/
|
||||
count: number;
|
||||
/**
|
||||
* Time in milliseconds remaining before the count resets
|
||||
*/
|
||||
remainingTime: number;
|
||||
}
|
||||
/**
|
||||
* Represents a file to be added to the request
|
||||
*/
|
||||
interface RawFile {
|
||||
/**
|
||||
* Content-Type of the file
|
||||
*/
|
||||
contentType?: string;
|
||||
/**
|
||||
* The actual data for the file
|
||||
*/
|
||||
data: Buffer | Uint8Array | boolean | number | string;
|
||||
/**
|
||||
* An explicit key to use for key of the formdata field for this file.
|
||||
* When not provided, the index of the file in the files array is used in the form `files[${index}]`.
|
||||
* If you wish to alter the placeholder snowflake, you must provide this property in the same form (`files[${placeholder}]`)
|
||||
*/
|
||||
key?: string;
|
||||
/**
|
||||
* The name of the file
|
||||
*/
|
||||
name: string;
|
||||
}
|
||||
/**
|
||||
* Represents possible data to be given to an endpoint
|
||||
*/
|
||||
interface RequestData {
|
||||
/**
|
||||
* Whether to append JSON data to form data instead of `payload_json` when sending files
|
||||
*/
|
||||
appendToFormData?: boolean;
|
||||
/**
|
||||
* If this request needs the `Authorization` header
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
auth?: boolean;
|
||||
/**
|
||||
* The authorization prefix to use for this request, useful if you use this with bearer tokens
|
||||
*
|
||||
* @defaultValue `'Bot'`
|
||||
*/
|
||||
authPrefix?: 'Bearer' | 'Bot';
|
||||
/**
|
||||
* The body to send to this request.
|
||||
* If providing as BodyInit, set `passThroughBody: true`
|
||||
*/
|
||||
body?: BodyInit | unknown;
|
||||
/**
|
||||
* The {@link https://undici.nodejs.org/#/docs/api/Agent | Agent} to use for the request.
|
||||
*/
|
||||
dispatcher?: Agent;
|
||||
/**
|
||||
* Files to be attached to this request
|
||||
*/
|
||||
files?: RawFile[] | undefined;
|
||||
/**
|
||||
* Additional headers to add to this request
|
||||
*/
|
||||
headers?: Record<string, string>;
|
||||
/**
|
||||
* Whether to pass-through the body property directly to `fetch()`.
|
||||
* <warn>This only applies when files is NOT present</warn>
|
||||
*/
|
||||
passThroughBody?: boolean;
|
||||
/**
|
||||
* Query string parameters to append to the called endpoint
|
||||
*/
|
||||
query?: URLSearchParams;
|
||||
/**
|
||||
* Reason to show in the audit logs
|
||||
*/
|
||||
reason?: string | undefined;
|
||||
/**
|
||||
* The signal to abort the queue entry or the REST call, where applicable
|
||||
*/
|
||||
signal?: AbortSignal | undefined;
|
||||
/**
|
||||
* If this request should be versioned
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
versioned?: boolean;
|
||||
}
|
||||
/**
|
||||
* Possible headers for an API call
|
||||
*/
|
||||
interface RequestHeaders {
|
||||
Authorization?: string;
|
||||
'User-Agent': string;
|
||||
'X-Audit-Log-Reason'?: string;
|
||||
}
|
||||
/**
|
||||
* Possible API methods to be used when doing requests
|
||||
*/
|
||||
declare enum RequestMethod {
|
||||
Delete = "DELETE",
|
||||
Get = "GET",
|
||||
Patch = "PATCH",
|
||||
Post = "POST",
|
||||
Put = "PUT"
|
||||
}
|
||||
type RouteLike = `/${string}`;
|
||||
/**
|
||||
* Internal request options
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface InternalRequest extends RequestData {
|
||||
fullRoute: RouteLike;
|
||||
method: RequestMethod;
|
||||
}
|
||||
type HandlerRequestData = Pick<InternalRequest, 'auth' | 'body' | 'files' | 'signal'>;
|
||||
/**
|
||||
* Parsed route data for an endpoint
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface RouteData {
|
||||
bucketRoute: string;
|
||||
majorParameter: string;
|
||||
original: RouteLike;
|
||||
}
|
||||
/**
|
||||
* Represents a hash and its associated fields
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface HashData {
|
||||
lastAccess: number;
|
||||
value: string;
|
||||
}
|
||||
|
||||
declare const DefaultUserAgent: `DiscordBot (https://discord.js.org, ${string})`;
|
||||
/**
|
||||
* The default string to append onto the user agent.
|
||||
*/
|
||||
declare const DefaultUserAgentAppendix: string;
|
||||
declare const DefaultRestOptions: {
|
||||
readonly agent: null;
|
||||
readonly api: "https://discord.com/api";
|
||||
readonly authPrefix: "Bot";
|
||||
readonly cdn: "https://cdn.discordapp.com";
|
||||
readonly headers: {};
|
||||
readonly invalidRequestWarningInterval: 0;
|
||||
readonly globalRequestsPerSecond: 50;
|
||||
readonly offset: 50;
|
||||
readonly rejectOnRateLimit: null;
|
||||
readonly retries: 3;
|
||||
readonly timeout: 15000;
|
||||
readonly userAgentAppendix: string;
|
||||
readonly version: "10";
|
||||
readonly hashSweepInterval: 14400000;
|
||||
readonly hashLifetime: 86400000;
|
||||
readonly handlerSweepInterval: 3600000;
|
||||
readonly makeRequest: (url: string, init: undici.RequestInit) => Promise<ResponseLike>;
|
||||
};
|
||||
/**
|
||||
* The events that the REST manager emits
|
||||
*/
|
||||
declare enum RESTEvents {
|
||||
Debug = "restDebug",
|
||||
HandlerSweep = "handlerSweep",
|
||||
HashSweep = "hashSweep",
|
||||
InvalidRequestWarning = "invalidRequestWarning",
|
||||
RateLimited = "rateLimited",
|
||||
Response = "response"
|
||||
}
|
||||
declare const ALLOWED_EXTENSIONS: readonly ["webp", "png", "jpg", "jpeg", "gif"];
|
||||
declare const ALLOWED_STICKER_EXTENSIONS: readonly ["png", "json", "gif"];
|
||||
declare const ALLOWED_SIZES: readonly [16, 32, 64, 128, 256, 512, 1024, 2048, 4096];
|
||||
type ImageExtension = (typeof ALLOWED_EXTENSIONS)[number];
|
||||
type StickerExtension = (typeof ALLOWED_STICKER_EXTENSIONS)[number];
|
||||
type ImageSize = (typeof ALLOWED_SIZES)[number];
|
||||
declare const OverwrittenMimeTypes: {
|
||||
readonly 'image/apng': "image/png";
|
||||
};
|
||||
declare const BurstHandlerMajorIdKey = "burst";
|
||||
/**
|
||||
* Prefix for deprecation warnings.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
declare const DEPRECATION_WARNING_PREFIX: "DeprecationWarning";
|
||||
|
||||
/**
|
||||
* The options used for image URLs
|
||||
*/
|
||||
interface BaseImageURLOptions {
|
||||
/**
|
||||
* The extension to use for the image URL
|
||||
*
|
||||
* @defaultValue `'webp'`
|
||||
*/
|
||||
extension?: ImageExtension;
|
||||
/**
|
||||
* The size specified in the image URL
|
||||
*/
|
||||
size?: ImageSize;
|
||||
}
|
||||
/**
|
||||
* The options used for image URLs with animated content
|
||||
*/
|
||||
interface ImageURLOptions extends BaseImageURLOptions {
|
||||
/**
|
||||
* Whether or not to prefer the static version of an image asset.
|
||||
*/
|
||||
forceStatic?: boolean;
|
||||
}
|
||||
/**
|
||||
* The options to use when making a CDN URL
|
||||
*/
|
||||
interface MakeURLOptions {
|
||||
/**
|
||||
* The allowed extensions that can be used
|
||||
*/
|
||||
allowedExtensions?: readonly string[];
|
||||
/**
|
||||
* The extension to use for the image URL
|
||||
*
|
||||
* @defaultValue `'webp'`
|
||||
*/
|
||||
extension?: string | undefined;
|
||||
/**
|
||||
* The size specified in the image URL
|
||||
*/
|
||||
size?: ImageSize;
|
||||
}
|
||||
/**
|
||||
* The CDN link builder
|
||||
*/
|
||||
declare class CDN {
|
||||
private readonly base;
|
||||
constructor(base?: string);
|
||||
/**
|
||||
* Generates an app asset URL for a client's asset.
|
||||
*
|
||||
* @param clientId - The client id that has the asset
|
||||
* @param assetHash - The hash provided by Discord for this asset
|
||||
* @param options - Optional options for the asset
|
||||
*/
|
||||
appAsset(clientId: string, assetHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates an app icon URL for a client's icon.
|
||||
*
|
||||
* @param clientId - The client id that has the icon
|
||||
* @param iconHash - The hash provided by Discord for this icon
|
||||
* @param options - Optional options for the icon
|
||||
*/
|
||||
appIcon(clientId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates an avatar URL, e.g. for a user or a webhook.
|
||||
*
|
||||
* @param id - The id that has the icon
|
||||
* @param avatarHash - The hash provided by Discord for this avatar
|
||||
* @param options - Optional options for the avatar
|
||||
*/
|
||||
avatar(id: string, avatarHash: string, options?: Readonly<ImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a user avatar decoration URL.
|
||||
*
|
||||
* @param userId - The id of the user
|
||||
* @param userAvatarDecoration - The hash provided by Discord for this avatar decoration
|
||||
* @param options - Optional options for the avatar decoration
|
||||
*/
|
||||
avatarDecoration(userId: string, userAvatarDecoration: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a banner URL, e.g. for a user or a guild.
|
||||
*
|
||||
* @param id - The id that has the banner splash
|
||||
* @param bannerHash - The hash provided by Discord for this banner
|
||||
* @param options - Optional options for the banner
|
||||
*/
|
||||
banner(id: string, bannerHash: string, options?: Readonly<ImageURLOptions>): string;
|
||||
/**
|
||||
* Generates an icon URL for a channel, e.g. a group DM.
|
||||
*
|
||||
* @param channelId - The channel id that has the icon
|
||||
* @param iconHash - The hash provided by Discord for this channel
|
||||
* @param options - Optional options for the icon
|
||||
*/
|
||||
channelIcon(channelId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a default avatar URL
|
||||
*
|
||||
* @param index - The default avatar index
|
||||
* @remarks
|
||||
* To calculate the index for a user do `(userId >> 22) % 6`,
|
||||
* or `discriminator % 5` if they're using the legacy username system.
|
||||
*/
|
||||
defaultAvatar(index: number): string;
|
||||
/**
|
||||
* Generates a discovery splash URL for a guild's discovery splash.
|
||||
*
|
||||
* @param guildId - The guild id that has the discovery splash
|
||||
* @param splashHash - The hash provided by Discord for this splash
|
||||
* @param options - Optional options for the splash
|
||||
*/
|
||||
discoverySplash(guildId: string, splashHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates an emoji's URL for an emoji.
|
||||
*
|
||||
* @param emojiId - The emoji id
|
||||
* @param options - Optional options for the emoji
|
||||
*/
|
||||
emoji(emojiId: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates an emoji's URL for an emoji.
|
||||
*
|
||||
* @param emojiId - The emoji id
|
||||
* @param extension - The extension of the emoji
|
||||
* @deprecated This overload is deprecated. Pass an object containing the extension instead.
|
||||
*/
|
||||
emoji(emojiId: string, extension?: ImageExtension): string;
|
||||
/**
|
||||
* Generates a guild member avatar URL.
|
||||
*
|
||||
* @param guildId - The id of the guild
|
||||
* @param userId - The id of the user
|
||||
* @param avatarHash - The hash provided by Discord for this avatar
|
||||
* @param options - Optional options for the avatar
|
||||
*/
|
||||
guildMemberAvatar(guildId: string, userId: string, avatarHash: string, options?: Readonly<ImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a guild member banner URL.
|
||||
*
|
||||
* @param guildId - The id of the guild
|
||||
* @param userId - The id of the user
|
||||
* @param bannerHash - The hash provided by Discord for this banner
|
||||
* @param options - Optional options for the banner
|
||||
*/
|
||||
guildMemberBanner(guildId: string, userId: string, bannerHash: string, options?: Readonly<ImageURLOptions>): string;
|
||||
/**
|
||||
* Generates an icon URL, e.g. for a guild.
|
||||
*
|
||||
* @param id - The id that has the icon splash
|
||||
* @param iconHash - The hash provided by Discord for this icon
|
||||
* @param options - Optional options for the icon
|
||||
*/
|
||||
icon(id: string, iconHash: string, options?: Readonly<ImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a URL for the icon of a role
|
||||
*
|
||||
* @param roleId - The id of the role that has the icon
|
||||
* @param roleIconHash - The hash provided by Discord for this role icon
|
||||
* @param options - Optional options for the role icon
|
||||
*/
|
||||
roleIcon(roleId: string, roleIconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a guild invite splash URL for a guild's invite splash.
|
||||
*
|
||||
* @param guildId - The guild id that has the invite splash
|
||||
* @param splashHash - The hash provided by Discord for this splash
|
||||
* @param options - Optional options for the splash
|
||||
*/
|
||||
splash(guildId: string, splashHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a sticker URL.
|
||||
*
|
||||
* @param stickerId - The sticker id
|
||||
* @param extension - The extension of the sticker
|
||||
* @privateRemarks
|
||||
* Stickers cannot have a `.webp` extension, so we default to a `.png`
|
||||
*/
|
||||
sticker(stickerId: string, extension?: StickerExtension): string;
|
||||
/**
|
||||
* Generates a sticker pack banner URL.
|
||||
*
|
||||
* @param bannerId - The banner id
|
||||
* @param options - Optional options for the banner
|
||||
*/
|
||||
stickerPackBanner(bannerId: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a team icon URL for a team's icon.
|
||||
*
|
||||
* @param teamId - The team id that has the icon
|
||||
* @param iconHash - The hash provided by Discord for this icon
|
||||
* @param options - Optional options for the icon
|
||||
*/
|
||||
teamIcon(teamId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Generates a cover image for a guild scheduled event.
|
||||
*
|
||||
* @param scheduledEventId - The scheduled event id
|
||||
* @param coverHash - The hash provided by discord for this cover image
|
||||
* @param options - Optional options for the cover image
|
||||
*/
|
||||
guildScheduledEventCover(scheduledEventId: string, coverHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
/**
|
||||
* Constructs the URL for the resource, checking whether or not `hash` starts with `a_` if `dynamic` is set to `true`.
|
||||
*
|
||||
* @param route - The base cdn route
|
||||
* @param hash - The hash provided by Discord for this icon
|
||||
* @param options - Optional options for the link
|
||||
*/
|
||||
private dynamicMakeURL;
|
||||
/**
|
||||
* Constructs the URL for the resource
|
||||
*
|
||||
* @param route - The base cdn route
|
||||
* @param options - The extension/size options for the link
|
||||
*/
|
||||
private makeURL;
|
||||
}
|
||||
|
||||
interface DiscordErrorFieldInformation {
|
||||
code: string;
|
||||
message: string;
|
||||
}
|
||||
interface DiscordErrorGroupWrapper {
|
||||
_errors: DiscordError[];
|
||||
}
|
||||
type DiscordError = DiscordErrorFieldInformation | DiscordErrorGroupWrapper | string | {
|
||||
[k: string]: DiscordError;
|
||||
};
|
||||
interface DiscordErrorData {
|
||||
code: number;
|
||||
errors?: DiscordError;
|
||||
message: string;
|
||||
}
|
||||
interface OAuthErrorData {
|
||||
error: string;
|
||||
error_description?: string;
|
||||
}
|
||||
interface RequestBody {
|
||||
files: RawFile[] | undefined;
|
||||
json: unknown | undefined;
|
||||
}
|
||||
/**
|
||||
* Represents an API error returned by Discord
|
||||
*/
|
||||
declare class DiscordAPIError extends Error {
|
||||
rawError: DiscordErrorData | OAuthErrorData;
|
||||
code: number | string;
|
||||
status: number;
|
||||
method: string;
|
||||
url: string;
|
||||
requestBody: RequestBody;
|
||||
/**
|
||||
* @param rawError - The error reported by Discord
|
||||
* @param code - The error code reported by Discord
|
||||
* @param status - The status code of the response
|
||||
* @param method - The method of the request that erred
|
||||
* @param url - The url of the request that erred
|
||||
* @param bodyData - The unparsed data for the request that errored
|
||||
*/
|
||||
constructor(rawError: DiscordErrorData | OAuthErrorData, code: number | string, status: number, method: string, url: string, bodyData: Pick<InternalRequest, 'body' | 'files'>);
|
||||
/**
|
||||
* The name of the error
|
||||
*/
|
||||
get name(): string;
|
||||
private static getMessage;
|
||||
private static flattenDiscordError;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a HTTP error
|
||||
*/
|
||||
declare class HTTPError extends Error {
|
||||
status: number;
|
||||
method: string;
|
||||
url: string;
|
||||
requestBody: RequestBody;
|
||||
name: string;
|
||||
/**
|
||||
* @param status - The status code of the response
|
||||
* @param statusText - The status text of the response
|
||||
* @param method - The method of the request that erred
|
||||
* @param url - The url of the request that erred
|
||||
* @param bodyData - The unparsed data for the request that errored
|
||||
*/
|
||||
constructor(status: number, statusText: string, method: string, url: string, bodyData: Pick<InternalRequest, 'body' | 'files'>);
|
||||
}
|
||||
|
||||
declare class RateLimitError extends Error implements RateLimitData {
|
||||
timeToReset: number;
|
||||
limit: number;
|
||||
method: string;
|
||||
hash: string;
|
||||
url: string;
|
||||
route: string;
|
||||
majorParameter: string;
|
||||
global: boolean;
|
||||
retryAfter: number;
|
||||
sublimitTimeout: number;
|
||||
scope: RateLimitData['scope'];
|
||||
constructor({ timeToReset, limit, method, hash, url, route, majorParameter, global, retryAfter, sublimitTimeout, scope, }: RateLimitData);
|
||||
/**
|
||||
* The name of the error
|
||||
*/
|
||||
get name(): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the class that manages handlers for endpoints
|
||||
*/
|
||||
declare class REST extends AsyncEventEmitter<RestEventsMap> {
|
||||
#private;
|
||||
/**
|
||||
* The {@link https://undici.nodejs.org/#/docs/api/Agent | Agent} for all requests
|
||||
* performed by this manager.
|
||||
*/
|
||||
agent: Dispatcher | null;
|
||||
readonly cdn: CDN;
|
||||
/**
|
||||
* The number of requests remaining in the global bucket
|
||||
*/
|
||||
globalRemaining: number;
|
||||
/**
|
||||
* The promise used to wait out the global rate limit
|
||||
*/
|
||||
globalDelay: Promise<void> | null;
|
||||
/**
|
||||
* The timestamp at which the global bucket resets
|
||||
*/
|
||||
globalReset: number;
|
||||
/**
|
||||
* API bucket hashes that are cached from provided routes
|
||||
*/
|
||||
readonly hashes: Collection<string, HashData>;
|
||||
/**
|
||||
* Request handlers created from the bucket hash and the major parameters
|
||||
*/
|
||||
readonly handlers: Collection<string, IHandler>;
|
||||
private hashTimer;
|
||||
private handlerTimer;
|
||||
readonly options: RESTOptions;
|
||||
constructor(options?: Partial<RESTOptions>);
|
||||
private setupSweepers;
|
||||
/**
|
||||
* Runs a get request from the api
|
||||
*
|
||||
* @param fullRoute - The full route to query
|
||||
* @param options - Optional request options
|
||||
*/
|
||||
get(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||
/**
|
||||
* Runs a delete request from the api
|
||||
*
|
||||
* @param fullRoute - The full route to query
|
||||
* @param options - Optional request options
|
||||
*/
|
||||
delete(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||
/**
|
||||
* Runs a post request from the api
|
||||
*
|
||||
* @param fullRoute - The full route to query
|
||||
* @param options - Optional request options
|
||||
*/
|
||||
post(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||
/**
|
||||
* Runs a put request from the api
|
||||
*
|
||||
* @param fullRoute - The full route to query
|
||||
* @param options - Optional request options
|
||||
*/
|
||||
put(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||
/**
|
||||
* Runs a patch request from the api
|
||||
*
|
||||
* @param fullRoute - The full route to query
|
||||
* @param options - Optional request options
|
||||
*/
|
||||
patch(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||
/**
|
||||
* Runs a request from the api
|
||||
*
|
||||
* @param options - Request options
|
||||
*/
|
||||
request(options: InternalRequest): Promise<unknown>;
|
||||
/**
|
||||
* Sets the default agent to use for requests performed by this manager
|
||||
*
|
||||
* @param agent - The agent to use
|
||||
*/
|
||||
setAgent(agent: Dispatcher): this;
|
||||
/**
|
||||
* Sets the authorization token that should be used for requests
|
||||
*
|
||||
* @param token - The authorization token to use
|
||||
*/
|
||||
setToken(token: string): this;
|
||||
/**
|
||||
* Queues a request to be sent
|
||||
*
|
||||
* @param request - All the information needed to make a request
|
||||
* @returns The response from the api request
|
||||
*/
|
||||
queueRequest(request: InternalRequest): Promise<ResponseLike>;
|
||||
/**
|
||||
* Creates a new rate limit handler from a hash, based on the hash and the major parameter
|
||||
*
|
||||
* @param hash - The hash for the route
|
||||
* @param majorParameter - The major parameter for this handler
|
||||
* @internal
|
||||
*/
|
||||
private createHandler;
|
||||
/**
|
||||
* Formats the request data to a usable format for fetch
|
||||
*
|
||||
* @param request - The request data
|
||||
*/
|
||||
private resolveRequest;
|
||||
/**
|
||||
* Stops the hash sweeping interval
|
||||
*/
|
||||
clearHashSweeper(): void;
|
||||
/**
|
||||
* Stops the request handler sweeping interval
|
||||
*/
|
||||
clearHandlerSweeper(): void;
|
||||
/**
|
||||
* Generates route data for an endpoint:method
|
||||
*
|
||||
* @param endpoint - The raw endpoint to generalize
|
||||
* @param method - The HTTP method this endpoint is called without
|
||||
* @internal
|
||||
*/
|
||||
private static generateRouteData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and populates an URLSearchParams instance from an object, stripping
|
||||
* out null and undefined values, while also coercing non-strings to strings.
|
||||
*
|
||||
* @param options - The options to use
|
||||
* @returns A populated URLSearchParams instance
|
||||
*/
|
||||
declare function makeURLSearchParams<OptionsType extends object>(options?: Readonly<OptionsType>): url.URLSearchParams;
|
||||
/**
|
||||
* Converts the response to usable data
|
||||
*
|
||||
* @param res - The fetch response
|
||||
*/
|
||||
declare function parseResponse(res: ResponseLike): Promise<unknown>;
|
||||
/**
|
||||
* Calculates the default avatar index for a given user id.
|
||||
*
|
||||
* @param userId - The user id to calculate the default avatar index for
|
||||
*/
|
||||
declare function calculateUserDefaultAvatarIndex(userId: Snowflake): number;
|
||||
|
||||
/**
|
||||
* The {@link https://github.com/discordjs/discord.js/blob/main/packages/rest#readme | @discordjs/rest} version
|
||||
* that you are currently using.
|
||||
*/
|
||||
declare const version: string;
|
||||
|
||||
export { ALLOWED_EXTENSIONS, ALLOWED_SIZES, ALLOWED_STICKER_EXTENSIONS, APIRequest, BaseImageURLOptions, BurstHandlerMajorIdKey, CDN, DEPRECATION_WARNING_PREFIX, DefaultRestOptions, DefaultUserAgent, DefaultUserAgentAppendix, DiscordAPIError, DiscordErrorData, HTTPError, HandlerRequestData, HashData, ImageExtension, ImageSize, ImageURLOptions, InternalRequest, InvalidRequestWarningData, MakeURLOptions, OAuthErrorData, OverwrittenMimeTypes, REST, RESTEvents, RESTOptions, RateLimitData, RateLimitError, RateLimitQueueFilter, RawFile, RequestBody, RequestData, RequestHeaders, RequestMethod, ResponseLike, RestEvents, RestEventsMap, RouteData, RouteLike, StickerExtension, calculateUserDefaultAvatarIndex, makeURLSearchParams, parseResponse, version };
|
1406
node_modules/@discordjs/rest/dist/web.js
generated
vendored
Normal file
1406
node_modules/@discordjs/rest/dist/web.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
node_modules/@discordjs/rest/dist/web.js.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/dist/web.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1362
node_modules/@discordjs/rest/dist/web.mjs
generated
vendored
Normal file
1362
node_modules/@discordjs/rest/dist/web.mjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
node_modules/@discordjs/rest/dist/web.mjs.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/dist/web.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
191
node_modules/@discordjs/rest/node_modules/@discordjs/collection/LICENSE
generated
vendored
Normal file
191
node_modules/@discordjs/rest/node_modules/@discordjs/collection/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,191 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Copyright 2021 Noel Buechler
|
||||
Copyright 2015 Amish Shah
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
67
node_modules/@discordjs/rest/node_modules/@discordjs/collection/README.md
generated
vendored
Normal file
67
node_modules/@discordjs/rest/node_modules/@discordjs/collection/README.md
generated
vendored
Normal file
|
@ -0,0 +1,67 @@
|
|||
<div align="center">
|
||||
<br />
|
||||
<p>
|
||||
<a href="https://discord.js.org"><img src="https://discord.js.org/static/logo.svg" width="546" alt="discord.js" /></a>
|
||||
</p>
|
||||
<br />
|
||||
<p>
|
||||
<a href="https://discord.gg/djs"><img src="https://img.shields.io/discord/222078108977594368?color=5865F2&logo=discord&logoColor=white" alt="Discord server" /></a>
|
||||
<a href="https://www.npmjs.com/package/@discordjs/collection"><img src="https://img.shields.io/npm/v/@discordjs/collection.svg?maxAge=3600" alt="npm version" /></a>
|
||||
<a href="https://www.npmjs.com/package/@discordjs/collection"><img src="https://img.shields.io/npm/dt/@discordjs/collection.svg?maxAge=3600" alt="npm downloads" /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Build status" /></a>
|
||||
<a href="https://codecov.io/gh/discordjs/discord.js" ><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2&flag=collection" alt="Code coverage" /></a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
|
||||
<a href="https://www.cloudflare.com"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-workers.png" alt="Cloudflare Workers" height="44" /></a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
## About
|
||||
|
||||
`@discordjs/collection` is a powerful utility data structure used in discord.js.
|
||||
|
||||
## Installation
|
||||
|
||||
**Node.js 18 or newer is required.**
|
||||
|
||||
```sh
|
||||
npm install @discordjs/collection
|
||||
yarn add @discordjs/collection
|
||||
pnpm add @discordjs/collection
|
||||
```
|
||||
|
||||
## Links
|
||||
|
||||
- [Website][website] ([source][website-source])
|
||||
- [Documentation][documentation]
|
||||
- [Guide][guide] ([source][guide-source])
|
||||
Also see the v13 to v14 [Update Guide][guide-update], which includes updated and removed items from the library.
|
||||
- [discord.js Discord server][discord]
|
||||
- [Discord API Discord server][discord-api]
|
||||
- [GitHub][source]
|
||||
- [npm][npm]
|
||||
- [Related libraries][related-libs]
|
||||
|
||||
## Contributing
|
||||
|
||||
Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the
|
||||
[documentation][documentation].
|
||||
See [the contribution guide][contributing] if you'd like to submit a PR.
|
||||
|
||||
## Help
|
||||
|
||||
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to join our official [discord.js Server][discord].
|
||||
|
||||
[website]: https://discord.js.org
|
||||
[website-source]: https://github.com/discordjs/discord.js/tree/main/apps/website
|
||||
[documentation]: https://discord.js.org/docs/packages/collection/stable
|
||||
[guide]: https://discordjs.guide/
|
||||
[guide-source]: https://github.com/discordjs/guide
|
||||
[guide-update]: https://discordjs.guide/additional-info/changes-in-v14.html
|
||||
[discord]: https://discord.gg/djs
|
||||
[discord-api]: https://discord.gg/discord-api
|
||||
[source]: https://github.com/discordjs/discord.js/tree/main/packages/collection
|
||||
[npm]: https://www.npmjs.com/package/@discordjs/collection
|
||||
[related-libs]: https://discord.com/developers/docs/topics/community-resources#libraries
|
||||
[contributing]: https://github.com/discordjs/discord.js/blob/main/.github/CONTRIBUTING.md
|
535
node_modules/@discordjs/rest/node_modules/@discordjs/collection/dist/index.d.mts
generated
vendored
Normal file
535
node_modules/@discordjs/rest/node_modules/@discordjs/collection/dist/index.d.mts
generated
vendored
Normal file
|
@ -0,0 +1,535 @@
|
|||
/**
|
||||
* @internal
|
||||
*/
|
||||
interface CollectionConstructor {
|
||||
new (): Collection<unknown, unknown>;
|
||||
new <Key, Value>(entries?: readonly (readonly [Key, Value])[] | null): Collection<Key, Value>;
|
||||
new <Key, Value>(iterable: Iterable<readonly [Key, Value]>): Collection<Key, Value>;
|
||||
readonly prototype: Collection<unknown, unknown>;
|
||||
readonly [Symbol.species]: CollectionConstructor;
|
||||
}
|
||||
/**
|
||||
* Represents an immutable version of a collection
|
||||
*/
|
||||
type ReadonlyCollection<Key, Value> = Omit<Collection<Key, Value>, 'delete' | 'ensure' | 'forEach' | 'get' | 'reverse' | 'set' | 'sort' | 'sweep'> & ReadonlyMap<Key, Value>;
|
||||
/**
|
||||
* Separate interface for the constructor so that emitted js does not have a constructor that overwrites itself
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface Collection<Key, Value> extends Map<Key, Value> {
|
||||
constructor: CollectionConstructor;
|
||||
}
|
||||
/**
|
||||
* A Map with additional utility methods. This is used throughout discord.js rather than Arrays for anything that has
|
||||
* an ID, for significantly improved performance and ease-of-use.
|
||||
*
|
||||
* @typeParam Key - The key type this collection holds
|
||||
* @typeParam Value - The value type this collection holds
|
||||
*/
|
||||
declare class Collection<Key, Value> extends Map<Key, Value> {
|
||||
/**
|
||||
* Obtains the value of the given key if it exists, otherwise sets and returns the value provided by the default value generator.
|
||||
*
|
||||
* @param key - The key to get if it exists, or set otherwise
|
||||
* @param defaultValueGenerator - A function that generates the default value
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.ensure(guildId, () => defaultGuildConfig);
|
||||
* ```
|
||||
*/
|
||||
ensure(key: Key, defaultValueGenerator: (key: Key, collection: this) => Value): Value;
|
||||
/**
|
||||
* Checks if all of the elements exist in the collection.
|
||||
*
|
||||
* @param keys - The keys of the elements to check for
|
||||
* @returns `true` if all of the elements exist, `false` if at least one does not exist.
|
||||
*/
|
||||
hasAll(...keys: Key[]): boolean;
|
||||
/**
|
||||
* Checks if any of the elements exist in the collection.
|
||||
*
|
||||
* @param keys - The keys of the elements to check for
|
||||
* @returns `true` if any of the elements exist, `false` if none exist.
|
||||
*/
|
||||
hasAny(...keys: Key[]): boolean;
|
||||
/**
|
||||
* Obtains the first value(s) in this collection.
|
||||
*
|
||||
* @param amount - Amount of values to obtain from the beginning
|
||||
* @returns A single value if no amount is provided or an array of values, starting from the end if amount is negative
|
||||
*/
|
||||
first(): Value | undefined;
|
||||
first(amount: number): Value[];
|
||||
/**
|
||||
* Obtains the first key(s) in this collection.
|
||||
*
|
||||
* @param amount - Amount of keys to obtain from the beginning
|
||||
* @returns A single key if no amount is provided or an array of keys, starting from the end if
|
||||
* amount is negative
|
||||
*/
|
||||
firstKey(): Key | undefined;
|
||||
firstKey(amount: number): Key[];
|
||||
/**
|
||||
* Obtains the last value(s) in this collection.
|
||||
*
|
||||
* @param amount - Amount of values to obtain from the end
|
||||
* @returns A single value if no amount is provided or an array of values, starting from the start if
|
||||
* amount is negative
|
||||
*/
|
||||
last(): Value | undefined;
|
||||
last(amount: number): Value[];
|
||||
/**
|
||||
* Obtains the last key(s) in this collection.
|
||||
*
|
||||
* @param amount - Amount of keys to obtain from the end
|
||||
* @returns A single key if no amount is provided or an array of keys, starting from the start if
|
||||
* amount is negative
|
||||
*/
|
||||
lastKey(): Key | undefined;
|
||||
lastKey(amount: number): Key[];
|
||||
/**
|
||||
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.
|
||||
* Returns the item at a given index, allowing for positive and negative integers.
|
||||
* Negative integers count back from the last item in the collection.
|
||||
*
|
||||
* @param index - The index of the element to obtain
|
||||
*/
|
||||
at(index: number): Value | undefined;
|
||||
/**
|
||||
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.
|
||||
* Returns the key at a given index, allowing for positive and negative integers.
|
||||
* Negative integers count back from the last item in the collection.
|
||||
*
|
||||
* @param index - The index of the key to obtain
|
||||
*/
|
||||
keyAt(index: number): Key | undefined;
|
||||
/**
|
||||
* Obtains unique random value(s) from this collection.
|
||||
*
|
||||
* @param amount - Amount of values to obtain randomly
|
||||
* @returns A single value if no amount is provided or an array of values
|
||||
*/
|
||||
random(): Value | undefined;
|
||||
random(amount: number): Value[];
|
||||
/**
|
||||
* Obtains unique random key(s) from this collection.
|
||||
*
|
||||
* @param amount - Amount of keys to obtain randomly
|
||||
* @returns A single key if no amount is provided or an array
|
||||
*/
|
||||
randomKey(): Key | undefined;
|
||||
randomKey(amount: number): Key[];
|
||||
/**
|
||||
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse | Array.reverse()}
|
||||
* but returns a Collection instead of an Array.
|
||||
*/
|
||||
reverse(): this;
|
||||
/**
|
||||
* Searches for a single item where the given function returns a truthy value. This behaves like
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find | Array.find()}.
|
||||
* All collections used in Discord.js are mapped using their `id` property, and if you want to find by id you
|
||||
* should use the `get` method. See
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get | MDN} for details.
|
||||
*
|
||||
* @param fn - The function to test with (should return a boolean)
|
||||
* @param thisArg - Value to use as `this` when executing the function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.find(user => user.username === 'Bob');
|
||||
* ```
|
||||
*/
|
||||
find<NewValue extends Value>(fn: (value: Value, key: Key, collection: this) => value is NewValue): NewValue | undefined;
|
||||
find(fn: (value: Value, key: Key, collection: this) => unknown): Value | undefined;
|
||||
find<This, NewValue extends Value>(fn: (this: This, value: Value, key: Key, collection: this) => value is NewValue, thisArg: This): NewValue | undefined;
|
||||
find<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): Value | undefined;
|
||||
/**
|
||||
* Searches for the key of a single item where the given function returns a truthy value. This behaves like
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex | Array.findIndex()},
|
||||
* but returns the key rather than the positional index.
|
||||
*
|
||||
* @param fn - The function to test with (should return a boolean)
|
||||
* @param thisArg - Value to use as `this` when executing the function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.findKey(user => user.username === 'Bob');
|
||||
* ```
|
||||
*/
|
||||
findKey<NewKey extends Key>(fn: (value: Value, key: Key, collection: this) => key is NewKey): NewKey | undefined;
|
||||
findKey(fn: (value: Value, key: Key, collection: this) => unknown): Key | undefined;
|
||||
findKey<This, NewKey extends Key>(fn: (this: This, value: Value, key: Key, collection: this) => key is NewKey, thisArg: This): NewKey | undefined;
|
||||
findKey<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): Key | undefined;
|
||||
/**
|
||||
* Searches for a last item where the given function returns a truthy value. This behaves like
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast | Array.findLast()}.
|
||||
*
|
||||
* @param fn - The function to test with (should return a boolean)
|
||||
* @param thisArg - Value to use as `this` when executing the function
|
||||
*/
|
||||
findLast<NewValue extends Value>(fn: (value: Value, key: Key, collection: this) => value is NewValue): NewValue | undefined;
|
||||
findLast(fn: (value: Value, key: Key, collection: this) => unknown): Value | undefined;
|
||||
findLast<This, NewValue extends Value>(fn: (this: This, value: Value, key: Key, collection: this) => value is NewValue, thisArg: This): NewValue | undefined;
|
||||
findLast<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): Value | undefined;
|
||||
/**
|
||||
* Searches for the key of a last item where the given function returns a truthy value. This behaves like
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex | Array.findLastIndex()},
|
||||
* but returns the key rather than the positional index.
|
||||
*
|
||||
* @param fn - The function to test with (should return a boolean)
|
||||
* @param thisArg - Value to use as `this` when executing the function
|
||||
*/
|
||||
findLastKey<NewKey extends Key>(fn: (value: Value, key: Key, collection: this) => key is NewKey): NewKey | undefined;
|
||||
findLastKey(fn: (value: Value, key: Key, collection: this) => unknown): Key | undefined;
|
||||
findLastKey<This, NewKey extends Key>(fn: (this: This, value: Value, key: Key, collection: this) => key is NewKey, thisArg: This): NewKey | undefined;
|
||||
findLastKey<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): Key | undefined;
|
||||
/**
|
||||
* Removes items that satisfy the provided filter function.
|
||||
*
|
||||
* @param fn - Function used to test (should return a boolean)
|
||||
* @param thisArg - Value to use as `this` when executing the function
|
||||
* @returns The number of removed entries
|
||||
*/
|
||||
sweep(fn: (value: Value, key: Key, collection: this) => unknown): number;
|
||||
sweep<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): number;
|
||||
/**
|
||||
* Identical to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter | Array.filter()},
|
||||
* but returns a Collection instead of an Array.
|
||||
*
|
||||
* @param fn - The function to test with (should return a boolean)
|
||||
* @param thisArg - Value to use as `this` when executing the function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.filter(user => user.username === 'Bob');
|
||||
* ```
|
||||
*/
|
||||
filter<NewKey extends Key>(fn: (value: Value, key: Key, collection: this) => key is NewKey): Collection<NewKey, Value>;
|
||||
filter<NewValue extends Value>(fn: (value: Value, key: Key, collection: this) => value is NewValue): Collection<Key, NewValue>;
|
||||
filter(fn: (value: Value, key: Key, collection: this) => unknown): Collection<Key, Value>;
|
||||
filter<This, NewKey extends Key>(fn: (this: This, value: Value, key: Key, collection: this) => key is NewKey, thisArg: This): Collection<NewKey, Value>;
|
||||
filter<This, NewValue extends Value>(fn: (this: This, value: Value, key: Key, collection: this) => value is NewValue, thisArg: This): Collection<Key, NewValue>;
|
||||
filter<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): Collection<Key, Value>;
|
||||
/**
|
||||
* Partitions the collection into two collections where the first collection
|
||||
* contains the items that passed and the second contains the items that failed.
|
||||
*
|
||||
* @param fn - Function used to test (should return a boolean)
|
||||
* @param thisArg - Value to use as `this` when executing the function
|
||||
* @example
|
||||
* ```ts
|
||||
* const [big, small] = collection.partition(guild => guild.memberCount > 250);
|
||||
* ```
|
||||
*/
|
||||
partition<NewKey extends Key>(fn: (value: Value, key: Key, collection: this) => key is NewKey): [Collection<NewKey, Value>, Collection<Exclude<Key, NewKey>, Value>];
|
||||
partition<NewValue extends Value>(fn: (value: Value, key: Key, collection: this) => value is NewValue): [Collection<Key, NewValue>, Collection<Key, Exclude<Value, NewValue>>];
|
||||
partition(fn: (value: Value, key: Key, collection: this) => unknown): [Collection<Key, Value>, Collection<Key, Value>];
|
||||
partition<This, NewKey extends Key>(fn: (this: This, value: Value, key: Key, collection: this) => key is NewKey, thisArg: This): [Collection<NewKey, Value>, Collection<Exclude<Key, NewKey>, Value>];
|
||||
partition<This, NewValue extends Value>(fn: (this: This, value: Value, key: Key, collection: this) => value is NewValue, thisArg: This): [Collection<Key, NewValue>, Collection<Key, Exclude<Value, NewValue>>];
|
||||
partition<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): [Collection<Key, Value>, Collection<Key, Value>];
|
||||
/**
|
||||
* Maps each item into a Collection, then joins the results into a single Collection. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap | Array.flatMap()}.
|
||||
*
|
||||
* @param fn - Function that produces a new Collection
|
||||
* @param thisArg - Value to use as `this` when executing the function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.flatMap(guild => guild.members.cache);
|
||||
* ```
|
||||
*/
|
||||
flatMap<NewValue>(fn: (value: Value, key: Key, collection: this) => Collection<Key, NewValue>): Collection<Key, NewValue>;
|
||||
flatMap<NewValue, This>(fn: (this: This, value: Value, key: Key, collection: this) => Collection<Key, NewValue>, thisArg: This): Collection<Key, NewValue>;
|
||||
/**
|
||||
* Maps each item to another value into an array. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}.
|
||||
*
|
||||
* @param fn - Function that produces an element of the new array, taking three arguments
|
||||
* @param thisArg - Value to use as `this` when executing the function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.map(user => user.tag);
|
||||
* ```
|
||||
*/
|
||||
map<NewValue>(fn: (value: Value, key: Key, collection: this) => NewValue): NewValue[];
|
||||
map<This, NewValue>(fn: (this: This, value: Value, key: Key, collection: this) => NewValue, thisArg: This): NewValue[];
|
||||
/**
|
||||
* Maps each item to another value into a collection. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}.
|
||||
*
|
||||
* @param fn - Function that produces an element of the new collection, taking three arguments
|
||||
* @param thisArg - Value to use as `this` when executing the function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.mapValues(user => user.tag);
|
||||
* ```
|
||||
*/
|
||||
mapValues<NewValue>(fn: (value: Value, key: Key, collection: this) => NewValue): Collection<Key, NewValue>;
|
||||
mapValues<This, NewValue>(fn: (this: This, value: Value, key: Key, collection: this) => NewValue, thisArg: This): Collection<Key, NewValue>;
|
||||
/**
|
||||
* Checks if there exists an item that passes a test. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some | Array.some()}.
|
||||
*
|
||||
* @param fn - Function used to test (should return a boolean)
|
||||
* @param thisArg - Value to use as `this` when executing the function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.some(user => user.discriminator === '0000');
|
||||
* ```
|
||||
*/
|
||||
some(fn: (value: Value, key: Key, collection: this) => unknown): boolean;
|
||||
some<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): boolean;
|
||||
/**
|
||||
* Checks if all items passes a test. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every | Array.every()}.
|
||||
*
|
||||
* @param fn - Function used to test (should return a boolean)
|
||||
* @param thisArg - Value to use as `this` when executing the function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.every(user => !user.bot);
|
||||
* ```
|
||||
*/
|
||||
every<NewKey extends Key>(fn: (value: Value, key: Key, collection: this) => key is NewKey): this is Collection<NewKey, Value>;
|
||||
every<NewValue extends Value>(fn: (value: Value, key: Key, collection: this) => value is NewValue): this is Collection<Key, NewValue>;
|
||||
every(fn: (value: Value, key: Key, collection: this) => unknown): boolean;
|
||||
every<This, NewKey extends Key>(fn: (this: This, value: Value, key: Key, collection: this) => key is NewKey, thisArg: This): this is Collection<NewKey, Value>;
|
||||
every<This, NewValue extends Value>(fn: (this: This, value: Value, key: Key, collection: this) => value is NewValue, thisArg: This): this is Collection<Key, NewValue>;
|
||||
every<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): boolean;
|
||||
/**
|
||||
* Applies a function to produce a single value. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce | Array.reduce()}.
|
||||
*
|
||||
* @param fn - Function used to reduce, taking four arguments; `accumulator`, `currentValue`, `currentKey`,
|
||||
* and `collection`
|
||||
* @param initialValue - Starting value for the accumulator
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.reduce((acc, guild) => acc + guild.memberCount, 0);
|
||||
* ```
|
||||
*/
|
||||
reduce<InitialValue = Value>(fn: (accumulator: InitialValue, value: Value, key: Key, collection: this) => InitialValue, initialValue?: InitialValue): InitialValue;
|
||||
/**
|
||||
* Applies a function to produce a single value. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight | Array.reduceRight()}.
|
||||
*
|
||||
* @param fn - Function used to reduce, taking four arguments; `accumulator`, `value`, `key`, and `collection`
|
||||
* @param initialValue - Starting value for the accumulator
|
||||
*/
|
||||
reduceRight<InitialValue>(fn: (accumulator: InitialValue, value: Value, key: Key, collection: this) => InitialValue, initialValue?: InitialValue): InitialValue;
|
||||
/**
|
||||
* Identical to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach | Map.forEach()},
|
||||
* but returns the collection instead of undefined.
|
||||
*
|
||||
* @param fn - Function to execute for each element
|
||||
* @param thisArg - Value to use as `this` when executing the function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection
|
||||
* .each(user => console.log(user.username))
|
||||
* .filter(user => user.bot)
|
||||
* .each(user => console.log(user.username));
|
||||
* ```
|
||||
*/
|
||||
each(fn: (value: Value, key: Key, collection: this) => void): this;
|
||||
each<This>(fn: (this: This, value: Value, key: Key, collection: this) => void, thisArg: This): this;
|
||||
/**
|
||||
* Runs a function on the collection and returns the collection.
|
||||
*
|
||||
* @param fn - Function to execute
|
||||
* @param thisArg - Value to use as `this` when executing the function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection
|
||||
* .tap(coll => console.log(coll.size))
|
||||
* .filter(user => user.bot)
|
||||
* .tap(coll => console.log(coll.size))
|
||||
* ```
|
||||
*/
|
||||
tap(fn: (collection: this) => void): this;
|
||||
tap<This>(fn: (this: This, collection: this) => void, thisArg: This): this;
|
||||
/**
|
||||
* Creates an identical shallow copy of this collection.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const newColl = someColl.clone();
|
||||
* ```
|
||||
*/
|
||||
clone(): Collection<Key, Value>;
|
||||
/**
|
||||
* Combines this collection with others into a new collection. None of the source collections are modified.
|
||||
*
|
||||
* @param collections - Collections to merge
|
||||
* @example
|
||||
* ```ts
|
||||
* const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);
|
||||
* ```
|
||||
*/
|
||||
concat(...collections: ReadonlyCollection<Key, Value>[]): Collection<Key, Value>;
|
||||
/**
|
||||
* Checks if this collection shares identical items with another.
|
||||
* This is different to checking for equality using equal-signs, because
|
||||
* the collections may be different objects, but contain the same data.
|
||||
*
|
||||
* @param collection - Collection to compare with
|
||||
* @returns Whether the collections have identical contents
|
||||
*/
|
||||
equals(collection: ReadonlyCollection<Key, Value>): boolean;
|
||||
/**
|
||||
* The sort method sorts the items of a collection in place and returns it.
|
||||
* The sort is not necessarily stable in Node 10 or older.
|
||||
* The default sort order is according to string Unicode code points.
|
||||
*
|
||||
* @param compareFunction - Specifies a function that defines the sort order.
|
||||
* If omitted, the collection is sorted according to each character's Unicode code point value, according to the string conversion of each element.
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.sort((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
||||
* ```
|
||||
*/
|
||||
sort(compareFunction?: Comparator<Key, Value>): this;
|
||||
/**
|
||||
* The intersection method returns a new collection containing the items where the key is present in both collections.
|
||||
*
|
||||
* @param other - The other Collection to filter against
|
||||
* @example
|
||||
* ```ts
|
||||
* const col1 = new Collection([['a', 1], ['b', 2]]);
|
||||
* const col2 = new Collection([['a', 1], ['c', 3]]);
|
||||
* const intersection = col1.intersection(col2);
|
||||
* console.log(col1.intersection(col2));
|
||||
* // => Collection { 'a' => 1 }
|
||||
* ```
|
||||
*/
|
||||
intersection(other: ReadonlyCollection<Key, any>): Collection<Key, Value>;
|
||||
/**
|
||||
* Returns a new collection containing the items where the key is present in either of the collections.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* If the collections have any items with the same key, the value from the first collection will be used.
|
||||
* @param other - The other Collection to filter against
|
||||
* @example
|
||||
* ```ts
|
||||
* const col1 = new Collection([['a', 1], ['b', 2]]);
|
||||
* const col2 = new Collection([['a', 1], ['b', 3], ['c', 3]]);
|
||||
* const union = col1.union(col2);
|
||||
* console.log(union);
|
||||
* // => Collection { 'a' => 1, 'b' => 2, 'c' => 3 }
|
||||
* ```
|
||||
*/
|
||||
union<OtherValue>(other: ReadonlyCollection<Key, OtherValue>): Collection<Key, OtherValue | Value>;
|
||||
/**
|
||||
* Returns a new collection containing the items where the key is present in this collection but not the other.
|
||||
*
|
||||
* @param other - The other Collection to filter against
|
||||
* @example
|
||||
* ```ts
|
||||
* const col1 = new Collection([['a', 1], ['b', 2]]);
|
||||
* const col2 = new Collection([['a', 1], ['c', 3]]);
|
||||
* console.log(col1.difference(col2));
|
||||
* // => Collection { 'b' => 2 }
|
||||
* console.log(col2.difference(col1));
|
||||
* // => Collection { 'c' => 3 }
|
||||
* ```
|
||||
*/
|
||||
difference(other: ReadonlyCollection<Key, any>): Collection<Key, Value>;
|
||||
/**
|
||||
* Returns a new collection containing only the items where the keys are present in either collection, but not both.
|
||||
*
|
||||
* @param other - The other Collection to filter against
|
||||
* @example
|
||||
* ```ts
|
||||
* const col1 = new Collection([['a', 1], ['b', 2]]);
|
||||
* const col2 = new Collection([['a', 1], ['c', 3]]);
|
||||
* const symmetricDifference = col1.symmetricDifference(col2);
|
||||
* console.log(col1.symmetricDifference(col2));
|
||||
* // => Collection { 'b' => 2, 'c' => 3 }
|
||||
* ```
|
||||
*/
|
||||
symmetricDifference<OtherValue>(other: ReadonlyCollection<Key, OtherValue>): Collection<Key, OtherValue | Value>;
|
||||
/**
|
||||
* Merges two Collections together into a new Collection.
|
||||
*
|
||||
* @param other - The other Collection to merge with
|
||||
* @param whenInSelf - Function getting the result if the entry only exists in this Collection
|
||||
* @param whenInOther - Function getting the result if the entry only exists in the other Collection
|
||||
* @param whenInBoth - Function getting the result if the entry exists in both Collections
|
||||
* @example
|
||||
* ```ts
|
||||
* // Sums up the entries in two collections.
|
||||
* coll.merge(
|
||||
* other,
|
||||
* x => ({ keep: true, value: x }),
|
||||
* y => ({ keep: true, value: y }),
|
||||
* (x, y) => ({ keep: true, value: x + y }),
|
||||
* );
|
||||
* ```
|
||||
* @example
|
||||
* ```ts
|
||||
* // Intersects two collections in a left-biased manner.
|
||||
* coll.merge(
|
||||
* other,
|
||||
* x => ({ keep: false }),
|
||||
* y => ({ keep: false }),
|
||||
* (x, _) => ({ keep: true, value: x }),
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
merge<OtherValue, ResultValue>(other: ReadonlyCollection<Key, OtherValue>, whenInSelf: (value: Value, key: Key) => Keep<ResultValue>, whenInOther: (valueOther: OtherValue, key: Key) => Keep<ResultValue>, whenInBoth: (value: Value, valueOther: OtherValue, key: Key) => Keep<ResultValue>): Collection<Key, ResultValue>;
|
||||
/**
|
||||
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toReversed | Array.toReversed()}
|
||||
* but returns a Collection instead of an Array.
|
||||
*/
|
||||
toReversed(): Collection<Key, Value>;
|
||||
/**
|
||||
* The sorted method sorts the items of a collection and returns it.
|
||||
* The sort is not necessarily stable in Node 10 or older.
|
||||
* The default sort order is according to string Unicode code points.
|
||||
*
|
||||
* @param compareFunction - Specifies a function that defines the sort order.
|
||||
* If omitted, the collection is sorted according to each character's Unicode code point value,
|
||||
* according to the string conversion of each element.
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.sorted((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
||||
* ```
|
||||
*/
|
||||
toSorted(compareFunction?: Comparator<Key, Value>): Collection<Key, Value>;
|
||||
toJSON(): [Key, Value][];
|
||||
private static defaultSort;
|
||||
/**
|
||||
* Creates a Collection from a list of entries.
|
||||
*
|
||||
* @param entries - The list of entries
|
||||
* @param combine - Function to combine an existing entry with a new one
|
||||
* @example
|
||||
* ```ts
|
||||
* Collection.combineEntries([["a", 1], ["b", 2], ["a", 2]], (x, y) => x + y);
|
||||
* // returns Collection { "a" => 3, "b" => 2 }
|
||||
* ```
|
||||
*/
|
||||
static combineEntries<Key, Value>(entries: Iterable<[Key, Value]>, combine: (firstValue: Value, secondValue: Value, key: Key) => Value): Collection<Key, Value>;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type Keep<Value> = {
|
||||
keep: false;
|
||||
} | {
|
||||
keep: true;
|
||||
value: Value;
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type Comparator<Key, Value> = (firstValue: Value, secondValue: Value, firstKey: Key, secondKey: Key) => number;
|
||||
|
||||
/**
|
||||
* The {@link https://github.com/discordjs/discord.js/blob/main/packages/collection/#readme | @discordjs/collection} version
|
||||
* that you are currently using.
|
||||
*/
|
||||
declare const version: string;
|
||||
|
||||
export { Collection, CollectionConstructor, Comparator, Keep, ReadonlyCollection, version };
|
535
node_modules/@discordjs/rest/node_modules/@discordjs/collection/dist/index.d.ts
generated
vendored
Normal file
535
node_modules/@discordjs/rest/node_modules/@discordjs/collection/dist/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,535 @@
|
|||
/**
|
||||
* @internal
|
||||
*/
|
||||
interface CollectionConstructor {
|
||||
new (): Collection<unknown, unknown>;
|
||||
new <Key, Value>(entries?: readonly (readonly [Key, Value])[] | null): Collection<Key, Value>;
|
||||
new <Key, Value>(iterable: Iterable<readonly [Key, Value]>): Collection<Key, Value>;
|
||||
readonly prototype: Collection<unknown, unknown>;
|
||||
readonly [Symbol.species]: CollectionConstructor;
|
||||
}
|
||||
/**
|
||||
* Represents an immutable version of a collection
|
||||
*/
|
||||
type ReadonlyCollection<Key, Value> = Omit<Collection<Key, Value>, 'delete' | 'ensure' | 'forEach' | 'get' | 'reverse' | 'set' | 'sort' | 'sweep'> & ReadonlyMap<Key, Value>;
|
||||
/**
|
||||
* Separate interface for the constructor so that emitted js does not have a constructor that overwrites itself
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface Collection<Key, Value> extends Map<Key, Value> {
|
||||
constructor: CollectionConstructor;
|
||||
}
|
||||
/**
|
||||
* A Map with additional utility methods. This is used throughout discord.js rather than Arrays for anything that has
|
||||
* an ID, for significantly improved performance and ease-of-use.
|
||||
*
|
||||
* @typeParam Key - The key type this collection holds
|
||||
* @typeParam Value - The value type this collection holds
|
||||
*/
|
||||
declare class Collection<Key, Value> extends Map<Key, Value> {
|
||||
/**
|
||||
* Obtains the value of the given key if it exists, otherwise sets and returns the value provided by the default value generator.
|
||||
*
|
||||
* @param key - The key to get if it exists, or set otherwise
|
||||
* @param defaultValueGenerator - A function that generates the default value
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.ensure(guildId, () => defaultGuildConfig);
|
||||
* ```
|
||||
*/
|
||||
ensure(key: Key, defaultValueGenerator: (key: Key, collection: this) => Value): Value;
|
||||
/**
|
||||
* Checks if all of the elements exist in the collection.
|
||||
*
|
||||
* @param keys - The keys of the elements to check for
|
||||
* @returns `true` if all of the elements exist, `false` if at least one does not exist.
|
||||
*/
|
||||
hasAll(...keys: Key[]): boolean;
|
||||
/**
|
||||
* Checks if any of the elements exist in the collection.
|
||||
*
|
||||
* @param keys - The keys of the elements to check for
|
||||
* @returns `true` if any of the elements exist, `false` if none exist.
|
||||
*/
|
||||
hasAny(...keys: Key[]): boolean;
|
||||
/**
|
||||
* Obtains the first value(s) in this collection.
|
||||
*
|
||||
* @param amount - Amount of values to obtain from the beginning
|
||||
* @returns A single value if no amount is provided or an array of values, starting from the end if amount is negative
|
||||
*/
|
||||
first(): Value | undefined;
|
||||
first(amount: number): Value[];
|
||||
/**
|
||||
* Obtains the first key(s) in this collection.
|
||||
*
|
||||
* @param amount - Amount of keys to obtain from the beginning
|
||||
* @returns A single key if no amount is provided or an array of keys, starting from the end if
|
||||
* amount is negative
|
||||
*/
|
||||
firstKey(): Key | undefined;
|
||||
firstKey(amount: number): Key[];
|
||||
/**
|
||||
* Obtains the last value(s) in this collection.
|
||||
*
|
||||
* @param amount - Amount of values to obtain from the end
|
||||
* @returns A single value if no amount is provided or an array of values, starting from the start if
|
||||
* amount is negative
|
||||
*/
|
||||
last(): Value | undefined;
|
||||
last(amount: number): Value[];
|
||||
/**
|
||||
* Obtains the last key(s) in this collection.
|
||||
*
|
||||
* @param amount - Amount of keys to obtain from the end
|
||||
* @returns A single key if no amount is provided or an array of keys, starting from the start if
|
||||
* amount is negative
|
||||
*/
|
||||
lastKey(): Key | undefined;
|
||||
lastKey(amount: number): Key[];
|
||||
/**
|
||||
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.
|
||||
* Returns the item at a given index, allowing for positive and negative integers.
|
||||
* Negative integers count back from the last item in the collection.
|
||||
*
|
||||
* @param index - The index of the element to obtain
|
||||
*/
|
||||
at(index: number): Value | undefined;
|
||||
/**
|
||||
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.
|
||||
* Returns the key at a given index, allowing for positive and negative integers.
|
||||
* Negative integers count back from the last item in the collection.
|
||||
*
|
||||
* @param index - The index of the key to obtain
|
||||
*/
|
||||
keyAt(index: number): Key | undefined;
|
||||
/**
|
||||
* Obtains unique random value(s) from this collection.
|
||||
*
|
||||
* @param amount - Amount of values to obtain randomly
|
||||
* @returns A single value if no amount is provided or an array of values
|
||||
*/
|
||||
random(): Value | undefined;
|
||||
random(amount: number): Value[];
|
||||
/**
|
||||
* Obtains unique random key(s) from this collection.
|
||||
*
|
||||
* @param amount - Amount of keys to obtain randomly
|
||||
* @returns A single key if no amount is provided or an array
|
||||
*/
|
||||
randomKey(): Key | undefined;
|
||||
randomKey(amount: number): Key[];
|
||||
/**
|
||||
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse | Array.reverse()}
|
||||
* but returns a Collection instead of an Array.
|
||||
*/
|
||||
reverse(): this;
|
||||
/**
|
||||
* Searches for a single item where the given function returns a truthy value. This behaves like
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find | Array.find()}.
|
||||
* All collections used in Discord.js are mapped using their `id` property, and if you want to find by id you
|
||||
* should use the `get` method. See
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get | MDN} for details.
|
||||
*
|
||||
* @param fn - The function to test with (should return a boolean)
|
||||
* @param thisArg - Value to use as `this` when executing the function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.find(user => user.username === 'Bob');
|
||||
* ```
|
||||
*/
|
||||
find<NewValue extends Value>(fn: (value: Value, key: Key, collection: this) => value is NewValue): NewValue | undefined;
|
||||
find(fn: (value: Value, key: Key, collection: this) => unknown): Value | undefined;
|
||||
find<This, NewValue extends Value>(fn: (this: This, value: Value, key: Key, collection: this) => value is NewValue, thisArg: This): NewValue | undefined;
|
||||
find<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): Value | undefined;
|
||||
/**
|
||||
* Searches for the key of a single item where the given function returns a truthy value. This behaves like
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex | Array.findIndex()},
|
||||
* but returns the key rather than the positional index.
|
||||
*
|
||||
* @param fn - The function to test with (should return a boolean)
|
||||
* @param thisArg - Value to use as `this` when executing the function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.findKey(user => user.username === 'Bob');
|
||||
* ```
|
||||
*/
|
||||
findKey<NewKey extends Key>(fn: (value: Value, key: Key, collection: this) => key is NewKey): NewKey | undefined;
|
||||
findKey(fn: (value: Value, key: Key, collection: this) => unknown): Key | undefined;
|
||||
findKey<This, NewKey extends Key>(fn: (this: This, value: Value, key: Key, collection: this) => key is NewKey, thisArg: This): NewKey | undefined;
|
||||
findKey<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): Key | undefined;
|
||||
/**
|
||||
* Searches for a last item where the given function returns a truthy value. This behaves like
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast | Array.findLast()}.
|
||||
*
|
||||
* @param fn - The function to test with (should return a boolean)
|
||||
* @param thisArg - Value to use as `this` when executing the function
|
||||
*/
|
||||
findLast<NewValue extends Value>(fn: (value: Value, key: Key, collection: this) => value is NewValue): NewValue | undefined;
|
||||
findLast(fn: (value: Value, key: Key, collection: this) => unknown): Value | undefined;
|
||||
findLast<This, NewValue extends Value>(fn: (this: This, value: Value, key: Key, collection: this) => value is NewValue, thisArg: This): NewValue | undefined;
|
||||
findLast<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): Value | undefined;
|
||||
/**
|
||||
* Searches for the key of a last item where the given function returns a truthy value. This behaves like
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex | Array.findLastIndex()},
|
||||
* but returns the key rather than the positional index.
|
||||
*
|
||||
* @param fn - The function to test with (should return a boolean)
|
||||
* @param thisArg - Value to use as `this` when executing the function
|
||||
*/
|
||||
findLastKey<NewKey extends Key>(fn: (value: Value, key: Key, collection: this) => key is NewKey): NewKey | undefined;
|
||||
findLastKey(fn: (value: Value, key: Key, collection: this) => unknown): Key | undefined;
|
||||
findLastKey<This, NewKey extends Key>(fn: (this: This, value: Value, key: Key, collection: this) => key is NewKey, thisArg: This): NewKey | undefined;
|
||||
findLastKey<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): Key | undefined;
|
||||
/**
|
||||
* Removes items that satisfy the provided filter function.
|
||||
*
|
||||
* @param fn - Function used to test (should return a boolean)
|
||||
* @param thisArg - Value to use as `this` when executing the function
|
||||
* @returns The number of removed entries
|
||||
*/
|
||||
sweep(fn: (value: Value, key: Key, collection: this) => unknown): number;
|
||||
sweep<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): number;
|
||||
/**
|
||||
* Identical to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter | Array.filter()},
|
||||
* but returns a Collection instead of an Array.
|
||||
*
|
||||
* @param fn - The function to test with (should return a boolean)
|
||||
* @param thisArg - Value to use as `this` when executing the function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.filter(user => user.username === 'Bob');
|
||||
* ```
|
||||
*/
|
||||
filter<NewKey extends Key>(fn: (value: Value, key: Key, collection: this) => key is NewKey): Collection<NewKey, Value>;
|
||||
filter<NewValue extends Value>(fn: (value: Value, key: Key, collection: this) => value is NewValue): Collection<Key, NewValue>;
|
||||
filter(fn: (value: Value, key: Key, collection: this) => unknown): Collection<Key, Value>;
|
||||
filter<This, NewKey extends Key>(fn: (this: This, value: Value, key: Key, collection: this) => key is NewKey, thisArg: This): Collection<NewKey, Value>;
|
||||
filter<This, NewValue extends Value>(fn: (this: This, value: Value, key: Key, collection: this) => value is NewValue, thisArg: This): Collection<Key, NewValue>;
|
||||
filter<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): Collection<Key, Value>;
|
||||
/**
|
||||
* Partitions the collection into two collections where the first collection
|
||||
* contains the items that passed and the second contains the items that failed.
|
||||
*
|
||||
* @param fn - Function used to test (should return a boolean)
|
||||
* @param thisArg - Value to use as `this` when executing the function
|
||||
* @example
|
||||
* ```ts
|
||||
* const [big, small] = collection.partition(guild => guild.memberCount > 250);
|
||||
* ```
|
||||
*/
|
||||
partition<NewKey extends Key>(fn: (value: Value, key: Key, collection: this) => key is NewKey): [Collection<NewKey, Value>, Collection<Exclude<Key, NewKey>, Value>];
|
||||
partition<NewValue extends Value>(fn: (value: Value, key: Key, collection: this) => value is NewValue): [Collection<Key, NewValue>, Collection<Key, Exclude<Value, NewValue>>];
|
||||
partition(fn: (value: Value, key: Key, collection: this) => unknown): [Collection<Key, Value>, Collection<Key, Value>];
|
||||
partition<This, NewKey extends Key>(fn: (this: This, value: Value, key: Key, collection: this) => key is NewKey, thisArg: This): [Collection<NewKey, Value>, Collection<Exclude<Key, NewKey>, Value>];
|
||||
partition<This, NewValue extends Value>(fn: (this: This, value: Value, key: Key, collection: this) => value is NewValue, thisArg: This): [Collection<Key, NewValue>, Collection<Key, Exclude<Value, NewValue>>];
|
||||
partition<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): [Collection<Key, Value>, Collection<Key, Value>];
|
||||
/**
|
||||
* Maps each item into a Collection, then joins the results into a single Collection. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap | Array.flatMap()}.
|
||||
*
|
||||
* @param fn - Function that produces a new Collection
|
||||
* @param thisArg - Value to use as `this` when executing the function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.flatMap(guild => guild.members.cache);
|
||||
* ```
|
||||
*/
|
||||
flatMap<NewValue>(fn: (value: Value, key: Key, collection: this) => Collection<Key, NewValue>): Collection<Key, NewValue>;
|
||||
flatMap<NewValue, This>(fn: (this: This, value: Value, key: Key, collection: this) => Collection<Key, NewValue>, thisArg: This): Collection<Key, NewValue>;
|
||||
/**
|
||||
* Maps each item to another value into an array. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}.
|
||||
*
|
||||
* @param fn - Function that produces an element of the new array, taking three arguments
|
||||
* @param thisArg - Value to use as `this` when executing the function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.map(user => user.tag);
|
||||
* ```
|
||||
*/
|
||||
map<NewValue>(fn: (value: Value, key: Key, collection: this) => NewValue): NewValue[];
|
||||
map<This, NewValue>(fn: (this: This, value: Value, key: Key, collection: this) => NewValue, thisArg: This): NewValue[];
|
||||
/**
|
||||
* Maps each item to another value into a collection. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}.
|
||||
*
|
||||
* @param fn - Function that produces an element of the new collection, taking three arguments
|
||||
* @param thisArg - Value to use as `this` when executing the function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.mapValues(user => user.tag);
|
||||
* ```
|
||||
*/
|
||||
mapValues<NewValue>(fn: (value: Value, key: Key, collection: this) => NewValue): Collection<Key, NewValue>;
|
||||
mapValues<This, NewValue>(fn: (this: This, value: Value, key: Key, collection: this) => NewValue, thisArg: This): Collection<Key, NewValue>;
|
||||
/**
|
||||
* Checks if there exists an item that passes a test. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some | Array.some()}.
|
||||
*
|
||||
* @param fn - Function used to test (should return a boolean)
|
||||
* @param thisArg - Value to use as `this` when executing the function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.some(user => user.discriminator === '0000');
|
||||
* ```
|
||||
*/
|
||||
some(fn: (value: Value, key: Key, collection: this) => unknown): boolean;
|
||||
some<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): boolean;
|
||||
/**
|
||||
* Checks if all items passes a test. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every | Array.every()}.
|
||||
*
|
||||
* @param fn - Function used to test (should return a boolean)
|
||||
* @param thisArg - Value to use as `this` when executing the function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.every(user => !user.bot);
|
||||
* ```
|
||||
*/
|
||||
every<NewKey extends Key>(fn: (value: Value, key: Key, collection: this) => key is NewKey): this is Collection<NewKey, Value>;
|
||||
every<NewValue extends Value>(fn: (value: Value, key: Key, collection: this) => value is NewValue): this is Collection<Key, NewValue>;
|
||||
every(fn: (value: Value, key: Key, collection: this) => unknown): boolean;
|
||||
every<This, NewKey extends Key>(fn: (this: This, value: Value, key: Key, collection: this) => key is NewKey, thisArg: This): this is Collection<NewKey, Value>;
|
||||
every<This, NewValue extends Value>(fn: (this: This, value: Value, key: Key, collection: this) => value is NewValue, thisArg: This): this is Collection<Key, NewValue>;
|
||||
every<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): boolean;
|
||||
/**
|
||||
* Applies a function to produce a single value. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce | Array.reduce()}.
|
||||
*
|
||||
* @param fn - Function used to reduce, taking four arguments; `accumulator`, `currentValue`, `currentKey`,
|
||||
* and `collection`
|
||||
* @param initialValue - Starting value for the accumulator
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.reduce((acc, guild) => acc + guild.memberCount, 0);
|
||||
* ```
|
||||
*/
|
||||
reduce<InitialValue = Value>(fn: (accumulator: InitialValue, value: Value, key: Key, collection: this) => InitialValue, initialValue?: InitialValue): InitialValue;
|
||||
/**
|
||||
* Applies a function to produce a single value. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight | Array.reduceRight()}.
|
||||
*
|
||||
* @param fn - Function used to reduce, taking four arguments; `accumulator`, `value`, `key`, and `collection`
|
||||
* @param initialValue - Starting value for the accumulator
|
||||
*/
|
||||
reduceRight<InitialValue>(fn: (accumulator: InitialValue, value: Value, key: Key, collection: this) => InitialValue, initialValue?: InitialValue): InitialValue;
|
||||
/**
|
||||
* Identical to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach | Map.forEach()},
|
||||
* but returns the collection instead of undefined.
|
||||
*
|
||||
* @param fn - Function to execute for each element
|
||||
* @param thisArg - Value to use as `this` when executing the function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection
|
||||
* .each(user => console.log(user.username))
|
||||
* .filter(user => user.bot)
|
||||
* .each(user => console.log(user.username));
|
||||
* ```
|
||||
*/
|
||||
each(fn: (value: Value, key: Key, collection: this) => void): this;
|
||||
each<This>(fn: (this: This, value: Value, key: Key, collection: this) => void, thisArg: This): this;
|
||||
/**
|
||||
* Runs a function on the collection and returns the collection.
|
||||
*
|
||||
* @param fn - Function to execute
|
||||
* @param thisArg - Value to use as `this` when executing the function
|
||||
* @example
|
||||
* ```ts
|
||||
* collection
|
||||
* .tap(coll => console.log(coll.size))
|
||||
* .filter(user => user.bot)
|
||||
* .tap(coll => console.log(coll.size))
|
||||
* ```
|
||||
*/
|
||||
tap(fn: (collection: this) => void): this;
|
||||
tap<This>(fn: (this: This, collection: this) => void, thisArg: This): this;
|
||||
/**
|
||||
* Creates an identical shallow copy of this collection.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const newColl = someColl.clone();
|
||||
* ```
|
||||
*/
|
||||
clone(): Collection<Key, Value>;
|
||||
/**
|
||||
* Combines this collection with others into a new collection. None of the source collections are modified.
|
||||
*
|
||||
* @param collections - Collections to merge
|
||||
* @example
|
||||
* ```ts
|
||||
* const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);
|
||||
* ```
|
||||
*/
|
||||
concat(...collections: ReadonlyCollection<Key, Value>[]): Collection<Key, Value>;
|
||||
/**
|
||||
* Checks if this collection shares identical items with another.
|
||||
* This is different to checking for equality using equal-signs, because
|
||||
* the collections may be different objects, but contain the same data.
|
||||
*
|
||||
* @param collection - Collection to compare with
|
||||
* @returns Whether the collections have identical contents
|
||||
*/
|
||||
equals(collection: ReadonlyCollection<Key, Value>): boolean;
|
||||
/**
|
||||
* The sort method sorts the items of a collection in place and returns it.
|
||||
* The sort is not necessarily stable in Node 10 or older.
|
||||
* The default sort order is according to string Unicode code points.
|
||||
*
|
||||
* @param compareFunction - Specifies a function that defines the sort order.
|
||||
* If omitted, the collection is sorted according to each character's Unicode code point value, according to the string conversion of each element.
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.sort((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
||||
* ```
|
||||
*/
|
||||
sort(compareFunction?: Comparator<Key, Value>): this;
|
||||
/**
|
||||
* The intersection method returns a new collection containing the items where the key is present in both collections.
|
||||
*
|
||||
* @param other - The other Collection to filter against
|
||||
* @example
|
||||
* ```ts
|
||||
* const col1 = new Collection([['a', 1], ['b', 2]]);
|
||||
* const col2 = new Collection([['a', 1], ['c', 3]]);
|
||||
* const intersection = col1.intersection(col2);
|
||||
* console.log(col1.intersection(col2));
|
||||
* // => Collection { 'a' => 1 }
|
||||
* ```
|
||||
*/
|
||||
intersection(other: ReadonlyCollection<Key, any>): Collection<Key, Value>;
|
||||
/**
|
||||
* Returns a new collection containing the items where the key is present in either of the collections.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* If the collections have any items with the same key, the value from the first collection will be used.
|
||||
* @param other - The other Collection to filter against
|
||||
* @example
|
||||
* ```ts
|
||||
* const col1 = new Collection([['a', 1], ['b', 2]]);
|
||||
* const col2 = new Collection([['a', 1], ['b', 3], ['c', 3]]);
|
||||
* const union = col1.union(col2);
|
||||
* console.log(union);
|
||||
* // => Collection { 'a' => 1, 'b' => 2, 'c' => 3 }
|
||||
* ```
|
||||
*/
|
||||
union<OtherValue>(other: ReadonlyCollection<Key, OtherValue>): Collection<Key, OtherValue | Value>;
|
||||
/**
|
||||
* Returns a new collection containing the items where the key is present in this collection but not the other.
|
||||
*
|
||||
* @param other - The other Collection to filter against
|
||||
* @example
|
||||
* ```ts
|
||||
* const col1 = new Collection([['a', 1], ['b', 2]]);
|
||||
* const col2 = new Collection([['a', 1], ['c', 3]]);
|
||||
* console.log(col1.difference(col2));
|
||||
* // => Collection { 'b' => 2 }
|
||||
* console.log(col2.difference(col1));
|
||||
* // => Collection { 'c' => 3 }
|
||||
* ```
|
||||
*/
|
||||
difference(other: ReadonlyCollection<Key, any>): Collection<Key, Value>;
|
||||
/**
|
||||
* Returns a new collection containing only the items where the keys are present in either collection, but not both.
|
||||
*
|
||||
* @param other - The other Collection to filter against
|
||||
* @example
|
||||
* ```ts
|
||||
* const col1 = new Collection([['a', 1], ['b', 2]]);
|
||||
* const col2 = new Collection([['a', 1], ['c', 3]]);
|
||||
* const symmetricDifference = col1.symmetricDifference(col2);
|
||||
* console.log(col1.symmetricDifference(col2));
|
||||
* // => Collection { 'b' => 2, 'c' => 3 }
|
||||
* ```
|
||||
*/
|
||||
symmetricDifference<OtherValue>(other: ReadonlyCollection<Key, OtherValue>): Collection<Key, OtherValue | Value>;
|
||||
/**
|
||||
* Merges two Collections together into a new Collection.
|
||||
*
|
||||
* @param other - The other Collection to merge with
|
||||
* @param whenInSelf - Function getting the result if the entry only exists in this Collection
|
||||
* @param whenInOther - Function getting the result if the entry only exists in the other Collection
|
||||
* @param whenInBoth - Function getting the result if the entry exists in both Collections
|
||||
* @example
|
||||
* ```ts
|
||||
* // Sums up the entries in two collections.
|
||||
* coll.merge(
|
||||
* other,
|
||||
* x => ({ keep: true, value: x }),
|
||||
* y => ({ keep: true, value: y }),
|
||||
* (x, y) => ({ keep: true, value: x + y }),
|
||||
* );
|
||||
* ```
|
||||
* @example
|
||||
* ```ts
|
||||
* // Intersects two collections in a left-biased manner.
|
||||
* coll.merge(
|
||||
* other,
|
||||
* x => ({ keep: false }),
|
||||
* y => ({ keep: false }),
|
||||
* (x, _) => ({ keep: true, value: x }),
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
merge<OtherValue, ResultValue>(other: ReadonlyCollection<Key, OtherValue>, whenInSelf: (value: Value, key: Key) => Keep<ResultValue>, whenInOther: (valueOther: OtherValue, key: Key) => Keep<ResultValue>, whenInBoth: (value: Value, valueOther: OtherValue, key: Key) => Keep<ResultValue>): Collection<Key, ResultValue>;
|
||||
/**
|
||||
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toReversed | Array.toReversed()}
|
||||
* but returns a Collection instead of an Array.
|
||||
*/
|
||||
toReversed(): Collection<Key, Value>;
|
||||
/**
|
||||
* The sorted method sorts the items of a collection and returns it.
|
||||
* The sort is not necessarily stable in Node 10 or older.
|
||||
* The default sort order is according to string Unicode code points.
|
||||
*
|
||||
* @param compareFunction - Specifies a function that defines the sort order.
|
||||
* If omitted, the collection is sorted according to each character's Unicode code point value,
|
||||
* according to the string conversion of each element.
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.sorted((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
||||
* ```
|
||||
*/
|
||||
toSorted(compareFunction?: Comparator<Key, Value>): Collection<Key, Value>;
|
||||
toJSON(): [Key, Value][];
|
||||
private static defaultSort;
|
||||
/**
|
||||
* Creates a Collection from a list of entries.
|
||||
*
|
||||
* @param entries - The list of entries
|
||||
* @param combine - Function to combine an existing entry with a new one
|
||||
* @example
|
||||
* ```ts
|
||||
* Collection.combineEntries([["a", 1], ["b", 2], ["a", 2]], (x, y) => x + y);
|
||||
* // returns Collection { "a" => 3, "b" => 2 }
|
||||
* ```
|
||||
*/
|
||||
static combineEntries<Key, Value>(entries: Iterable<[Key, Value]>, combine: (firstValue: Value, secondValue: Value, key: Key) => Value): Collection<Key, Value>;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type Keep<Value> = {
|
||||
keep: false;
|
||||
} | {
|
||||
keep: true;
|
||||
value: Value;
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type Comparator<Key, Value> = (firstValue: Value, secondValue: Value, firstKey: Key, secondKey: Key) => number;
|
||||
|
||||
/**
|
||||
* The {@link https://github.com/discordjs/discord.js/blob/main/packages/collection/#readme | @discordjs/collection} version
|
||||
* that you are currently using.
|
||||
*/
|
||||
declare const version: string;
|
||||
|
||||
export { Collection, CollectionConstructor, Comparator, Keep, ReadonlyCollection, version };
|
654
node_modules/@discordjs/rest/node_modules/@discordjs/collection/dist/index.js
generated
vendored
Normal file
654
node_modules/@discordjs/rest/node_modules/@discordjs/collection/dist/index.js
generated
vendored
Normal file
|
@ -0,0 +1,654 @@
|
|||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/index.ts
|
||||
var src_exports = {};
|
||||
__export(src_exports, {
|
||||
Collection: () => Collection,
|
||||
version: () => version
|
||||
});
|
||||
module.exports = __toCommonJS(src_exports);
|
||||
|
||||
// src/collection.ts
|
||||
var Collection = class _Collection extends Map {
|
||||
static {
|
||||
__name(this, "Collection");
|
||||
}
|
||||
/**
|
||||
* Obtains the value of the given key if it exists, otherwise sets and returns the value provided by the default value generator.
|
||||
*
|
||||
* @param key - The key to get if it exists, or set otherwise
|
||||
* @param defaultValueGenerator - A function that generates the default value
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.ensure(guildId, () => defaultGuildConfig);
|
||||
* ```
|
||||
*/
|
||||
ensure(key, defaultValueGenerator) {
|
||||
if (this.has(key))
|
||||
return this.get(key);
|
||||
if (typeof defaultValueGenerator !== "function")
|
||||
throw new TypeError(`${defaultValueGenerator} is not a function`);
|
||||
const defaultValue = defaultValueGenerator(key, this);
|
||||
this.set(key, defaultValue);
|
||||
return defaultValue;
|
||||
}
|
||||
/**
|
||||
* Checks if all of the elements exist in the collection.
|
||||
*
|
||||
* @param keys - The keys of the elements to check for
|
||||
* @returns `true` if all of the elements exist, `false` if at least one does not exist.
|
||||
*/
|
||||
hasAll(...keys) {
|
||||
return keys.every((key) => super.has(key));
|
||||
}
|
||||
/**
|
||||
* Checks if any of the elements exist in the collection.
|
||||
*
|
||||
* @param keys - The keys of the elements to check for
|
||||
* @returns `true` if any of the elements exist, `false` if none exist.
|
||||
*/
|
||||
hasAny(...keys) {
|
||||
return keys.some((key) => super.has(key));
|
||||
}
|
||||
first(amount) {
|
||||
if (amount === void 0)
|
||||
return this.values().next().value;
|
||||
if (amount < 0)
|
||||
return this.last(amount * -1);
|
||||
amount = Math.min(this.size, amount);
|
||||
const iter = this.values();
|
||||
return Array.from({ length: amount }, () => iter.next().value);
|
||||
}
|
||||
firstKey(amount) {
|
||||
if (amount === void 0)
|
||||
return this.keys().next().value;
|
||||
if (amount < 0)
|
||||
return this.lastKey(amount * -1);
|
||||
amount = Math.min(this.size, amount);
|
||||
const iter = this.keys();
|
||||
return Array.from({ length: amount }, () => iter.next().value);
|
||||
}
|
||||
last(amount) {
|
||||
const arr = [...this.values()];
|
||||
if (amount === void 0)
|
||||
return arr[arr.length - 1];
|
||||
if (amount < 0)
|
||||
return this.first(amount * -1);
|
||||
if (!amount)
|
||||
return [];
|
||||
return arr.slice(-amount);
|
||||
}
|
||||
lastKey(amount) {
|
||||
const arr = [...this.keys()];
|
||||
if (amount === void 0)
|
||||
return arr[arr.length - 1];
|
||||
if (amount < 0)
|
||||
return this.firstKey(amount * -1);
|
||||
if (!amount)
|
||||
return [];
|
||||
return arr.slice(-amount);
|
||||
}
|
||||
/**
|
||||
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.
|
||||
* Returns the item at a given index, allowing for positive and negative integers.
|
||||
* Negative integers count back from the last item in the collection.
|
||||
*
|
||||
* @param index - The index of the element to obtain
|
||||
*/
|
||||
at(index) {
|
||||
index = Math.floor(index);
|
||||
const arr = [...this.values()];
|
||||
return arr.at(index);
|
||||
}
|
||||
/**
|
||||
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.
|
||||
* Returns the key at a given index, allowing for positive and negative integers.
|
||||
* Negative integers count back from the last item in the collection.
|
||||
*
|
||||
* @param index - The index of the key to obtain
|
||||
*/
|
||||
keyAt(index) {
|
||||
index = Math.floor(index);
|
||||
const arr = [...this.keys()];
|
||||
return arr.at(index);
|
||||
}
|
||||
random(amount) {
|
||||
const arr = [...this.values()];
|
||||
if (amount === void 0)
|
||||
return arr[Math.floor(Math.random() * arr.length)];
|
||||
if (!arr.length || !amount)
|
||||
return [];
|
||||
return Array.from(
|
||||
{ length: Math.min(amount, arr.length) },
|
||||
() => arr.splice(Math.floor(Math.random() * arr.length), 1)[0]
|
||||
);
|
||||
}
|
||||
randomKey(amount) {
|
||||
const arr = [...this.keys()];
|
||||
if (amount === void 0)
|
||||
return arr[Math.floor(Math.random() * arr.length)];
|
||||
if (!arr.length || !amount)
|
||||
return [];
|
||||
return Array.from(
|
||||
{ length: Math.min(amount, arr.length) },
|
||||
() => arr.splice(Math.floor(Math.random() * arr.length), 1)[0]
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse | Array.reverse()}
|
||||
* but returns a Collection instead of an Array.
|
||||
*/
|
||||
reverse() {
|
||||
const entries = [...this.entries()].reverse();
|
||||
this.clear();
|
||||
for (const [key, value] of entries)
|
||||
this.set(key, value);
|
||||
return this;
|
||||
}
|
||||
find(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
for (const [key, val] of this) {
|
||||
if (fn(val, key, this))
|
||||
return val;
|
||||
}
|
||||
return void 0;
|
||||
}
|
||||
findKey(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
for (const [key, val] of this) {
|
||||
if (fn(val, key, this))
|
||||
return key;
|
||||
}
|
||||
return void 0;
|
||||
}
|
||||
findLast(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
const entries = [...this.entries()];
|
||||
for (let index = entries.length - 1; index >= 0; index--) {
|
||||
const val = entries[index][1];
|
||||
const key = entries[index][0];
|
||||
if (fn(val, key, this))
|
||||
return val;
|
||||
}
|
||||
return void 0;
|
||||
}
|
||||
findLastKey(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
const entries = [...this.entries()];
|
||||
for (let index = entries.length - 1; index >= 0; index--) {
|
||||
const key = entries[index][0];
|
||||
const val = entries[index][1];
|
||||
if (fn(val, key, this))
|
||||
return key;
|
||||
}
|
||||
return void 0;
|
||||
}
|
||||
sweep(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
const previousSize = this.size;
|
||||
for (const [key, val] of this) {
|
||||
if (fn(val, key, this))
|
||||
this.delete(key);
|
||||
}
|
||||
return previousSize - this.size;
|
||||
}
|
||||
filter(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
const results = new this.constructor[Symbol.species]();
|
||||
for (const [key, val] of this) {
|
||||
if (fn(val, key, this))
|
||||
results.set(key, val);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
partition(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
const results = [
|
||||
new this.constructor[Symbol.species](),
|
||||
new this.constructor[Symbol.species]()
|
||||
];
|
||||
for (const [key, val] of this) {
|
||||
if (fn(val, key, this)) {
|
||||
results[0].set(key, val);
|
||||
} else {
|
||||
results[1].set(key, val);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
flatMap(fn, thisArg) {
|
||||
const collections = this.map(fn, thisArg);
|
||||
return new this.constructor[Symbol.species]().concat(...collections);
|
||||
}
|
||||
map(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
const iter = this.entries();
|
||||
return Array.from({ length: this.size }, () => {
|
||||
const [key, value] = iter.next().value;
|
||||
return fn(value, key, this);
|
||||
});
|
||||
}
|
||||
mapValues(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
const coll = new this.constructor[Symbol.species]();
|
||||
for (const [key, val] of this)
|
||||
coll.set(key, fn(val, key, this));
|
||||
return coll;
|
||||
}
|
||||
some(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
for (const [key, val] of this) {
|
||||
if (fn(val, key, this))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
every(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
for (const [key, val] of this) {
|
||||
if (!fn(val, key, this))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Applies a function to produce a single value. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce | Array.reduce()}.
|
||||
*
|
||||
* @param fn - Function used to reduce, taking four arguments; `accumulator`, `currentValue`, `currentKey`,
|
||||
* and `collection`
|
||||
* @param initialValue - Starting value for the accumulator
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.reduce((acc, guild) => acc + guild.memberCount, 0);
|
||||
* ```
|
||||
*/
|
||||
reduce(fn, initialValue) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
let accumulator;
|
||||
const iterator = this.entries();
|
||||
if (initialValue === void 0) {
|
||||
if (this.size === 0)
|
||||
throw new TypeError("Reduce of empty collection with no initial value");
|
||||
accumulator = iterator.next().value[1];
|
||||
} else {
|
||||
accumulator = initialValue;
|
||||
}
|
||||
for (const [key, value] of iterator) {
|
||||
accumulator = fn(accumulator, value, key, this);
|
||||
}
|
||||
return accumulator;
|
||||
}
|
||||
/**
|
||||
* Applies a function to produce a single value. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight | Array.reduceRight()}.
|
||||
*
|
||||
* @param fn - Function used to reduce, taking four arguments; `accumulator`, `value`, `key`, and `collection`
|
||||
* @param initialValue - Starting value for the accumulator
|
||||
*/
|
||||
reduceRight(fn, initialValue) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
const entries = [...this.entries()];
|
||||
let accumulator;
|
||||
let index;
|
||||
if (initialValue === void 0) {
|
||||
if (entries.length === 0)
|
||||
throw new TypeError("Reduce of empty collection with no initial value");
|
||||
accumulator = entries[entries.length - 1][1];
|
||||
index = entries.length - 1;
|
||||
} else {
|
||||
accumulator = initialValue;
|
||||
index = entries.length;
|
||||
}
|
||||
while (--index >= 0) {
|
||||
const key = entries[index][0];
|
||||
const val = entries[index][1];
|
||||
accumulator = fn(accumulator, val, key, this);
|
||||
}
|
||||
return accumulator;
|
||||
}
|
||||
each(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
for (const [key, value] of this) {
|
||||
fn(value, key, this);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
tap(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
fn(this);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Creates an identical shallow copy of this collection.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const newColl = someColl.clone();
|
||||
* ```
|
||||
*/
|
||||
clone() {
|
||||
return new this.constructor[Symbol.species](this);
|
||||
}
|
||||
/**
|
||||
* Combines this collection with others into a new collection. None of the source collections are modified.
|
||||
*
|
||||
* @param collections - Collections to merge
|
||||
* @example
|
||||
* ```ts
|
||||
* const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);
|
||||
* ```
|
||||
*/
|
||||
concat(...collections) {
|
||||
const newColl = this.clone();
|
||||
for (const coll of collections) {
|
||||
for (const [key, val] of coll)
|
||||
newColl.set(key, val);
|
||||
}
|
||||
return newColl;
|
||||
}
|
||||
/**
|
||||
* Checks if this collection shares identical items with another.
|
||||
* This is different to checking for equality using equal-signs, because
|
||||
* the collections may be different objects, but contain the same data.
|
||||
*
|
||||
* @param collection - Collection to compare with
|
||||
* @returns Whether the collections have identical contents
|
||||
*/
|
||||
equals(collection) {
|
||||
if (!collection)
|
||||
return false;
|
||||
if (this === collection)
|
||||
return true;
|
||||
if (this.size !== collection.size)
|
||||
return false;
|
||||
for (const [key, value] of this) {
|
||||
if (!collection.has(key) || value !== collection.get(key)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* The sort method sorts the items of a collection in place and returns it.
|
||||
* The sort is not necessarily stable in Node 10 or older.
|
||||
* The default sort order is according to string Unicode code points.
|
||||
*
|
||||
* @param compareFunction - Specifies a function that defines the sort order.
|
||||
* If omitted, the collection is sorted according to each character's Unicode code point value, according to the string conversion of each element.
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.sort((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
||||
* ```
|
||||
*/
|
||||
sort(compareFunction = _Collection.defaultSort) {
|
||||
const entries = [...this.entries()];
|
||||
entries.sort((a, b) => compareFunction(a[1], b[1], a[0], b[0]));
|
||||
super.clear();
|
||||
for (const [key, value] of entries) {
|
||||
super.set(key, value);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* The intersection method returns a new collection containing the items where the key is present in both collections.
|
||||
*
|
||||
* @param other - The other Collection to filter against
|
||||
* @example
|
||||
* ```ts
|
||||
* const col1 = new Collection([['a', 1], ['b', 2]]);
|
||||
* const col2 = new Collection([['a', 1], ['c', 3]]);
|
||||
* const intersection = col1.intersection(col2);
|
||||
* console.log(col1.intersection(col2));
|
||||
* // => Collection { 'a' => 1 }
|
||||
* ```
|
||||
*/
|
||||
intersection(other) {
|
||||
const coll = new this.constructor[Symbol.species]();
|
||||
for (const [key, value] of this) {
|
||||
if (other.has(key))
|
||||
coll.set(key, value);
|
||||
}
|
||||
return coll;
|
||||
}
|
||||
/**
|
||||
* Returns a new collection containing the items where the key is present in either of the collections.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* If the collections have any items with the same key, the value from the first collection will be used.
|
||||
* @param other - The other Collection to filter against
|
||||
* @example
|
||||
* ```ts
|
||||
* const col1 = new Collection([['a', 1], ['b', 2]]);
|
||||
* const col2 = new Collection([['a', 1], ['b', 3], ['c', 3]]);
|
||||
* const union = col1.union(col2);
|
||||
* console.log(union);
|
||||
* // => Collection { 'a' => 1, 'b' => 2, 'c' => 3 }
|
||||
* ```
|
||||
*/
|
||||
union(other) {
|
||||
const coll = new this.constructor[Symbol.species](this);
|
||||
for (const [key, value] of other) {
|
||||
if (!coll.has(key))
|
||||
coll.set(key, value);
|
||||
}
|
||||
return coll;
|
||||
}
|
||||
/**
|
||||
* Returns a new collection containing the items where the key is present in this collection but not the other.
|
||||
*
|
||||
* @param other - The other Collection to filter against
|
||||
* @example
|
||||
* ```ts
|
||||
* const col1 = new Collection([['a', 1], ['b', 2]]);
|
||||
* const col2 = new Collection([['a', 1], ['c', 3]]);
|
||||
* console.log(col1.difference(col2));
|
||||
* // => Collection { 'b' => 2 }
|
||||
* console.log(col2.difference(col1));
|
||||
* // => Collection { 'c' => 3 }
|
||||
* ```
|
||||
*/
|
||||
difference(other) {
|
||||
const coll = new this.constructor[Symbol.species]();
|
||||
for (const [key, value] of this) {
|
||||
if (!other.has(key))
|
||||
coll.set(key, value);
|
||||
}
|
||||
return coll;
|
||||
}
|
||||
/**
|
||||
* Returns a new collection containing only the items where the keys are present in either collection, but not both.
|
||||
*
|
||||
* @param other - The other Collection to filter against
|
||||
* @example
|
||||
* ```ts
|
||||
* const col1 = new Collection([['a', 1], ['b', 2]]);
|
||||
* const col2 = new Collection([['a', 1], ['c', 3]]);
|
||||
* const symmetricDifference = col1.symmetricDifference(col2);
|
||||
* console.log(col1.symmetricDifference(col2));
|
||||
* // => Collection { 'b' => 2, 'c' => 3 }
|
||||
* ```
|
||||
*/
|
||||
symmetricDifference(other) {
|
||||
const coll = new this.constructor[Symbol.species]();
|
||||
for (const [key, value] of this) {
|
||||
if (!other.has(key))
|
||||
coll.set(key, value);
|
||||
}
|
||||
for (const [key, value] of other) {
|
||||
if (!this.has(key))
|
||||
coll.set(key, value);
|
||||
}
|
||||
return coll;
|
||||
}
|
||||
/**
|
||||
* Merges two Collections together into a new Collection.
|
||||
*
|
||||
* @param other - The other Collection to merge with
|
||||
* @param whenInSelf - Function getting the result if the entry only exists in this Collection
|
||||
* @param whenInOther - Function getting the result if the entry only exists in the other Collection
|
||||
* @param whenInBoth - Function getting the result if the entry exists in both Collections
|
||||
* @example
|
||||
* ```ts
|
||||
* // Sums up the entries in two collections.
|
||||
* coll.merge(
|
||||
* other,
|
||||
* x => ({ keep: true, value: x }),
|
||||
* y => ({ keep: true, value: y }),
|
||||
* (x, y) => ({ keep: true, value: x + y }),
|
||||
* );
|
||||
* ```
|
||||
* @example
|
||||
* ```ts
|
||||
* // Intersects two collections in a left-biased manner.
|
||||
* coll.merge(
|
||||
* other,
|
||||
* x => ({ keep: false }),
|
||||
* y => ({ keep: false }),
|
||||
* (x, _) => ({ keep: true, value: x }),
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
merge(other, whenInSelf, whenInOther, whenInBoth) {
|
||||
const coll = new this.constructor[Symbol.species]();
|
||||
const keys = /* @__PURE__ */ new Set([...this.keys(), ...other.keys()]);
|
||||
for (const key of keys) {
|
||||
const hasInSelf = this.has(key);
|
||||
const hasInOther = other.has(key);
|
||||
if (hasInSelf && hasInOther) {
|
||||
const result = whenInBoth(this.get(key), other.get(key), key);
|
||||
if (result.keep)
|
||||
coll.set(key, result.value);
|
||||
} else if (hasInSelf) {
|
||||
const result = whenInSelf(this.get(key), key);
|
||||
if (result.keep)
|
||||
coll.set(key, result.value);
|
||||
} else if (hasInOther) {
|
||||
const result = whenInOther(other.get(key), key);
|
||||
if (result.keep)
|
||||
coll.set(key, result.value);
|
||||
}
|
||||
}
|
||||
return coll;
|
||||
}
|
||||
/**
|
||||
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toReversed | Array.toReversed()}
|
||||
* but returns a Collection instead of an Array.
|
||||
*/
|
||||
toReversed() {
|
||||
return new this.constructor[Symbol.species](this).reverse();
|
||||
}
|
||||
/**
|
||||
* The sorted method sorts the items of a collection and returns it.
|
||||
* The sort is not necessarily stable in Node 10 or older.
|
||||
* The default sort order is according to string Unicode code points.
|
||||
*
|
||||
* @param compareFunction - Specifies a function that defines the sort order.
|
||||
* If omitted, the collection is sorted according to each character's Unicode code point value,
|
||||
* according to the string conversion of each element.
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.sorted((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
||||
* ```
|
||||
*/
|
||||
toSorted(compareFunction = _Collection.defaultSort) {
|
||||
return new this.constructor[Symbol.species](this).sort((av, bv, ak, bk) => compareFunction(av, bv, ak, bk));
|
||||
}
|
||||
toJSON() {
|
||||
return [...this.entries()];
|
||||
}
|
||||
static defaultSort(firstValue, secondValue) {
|
||||
return Number(firstValue > secondValue) || Number(firstValue === secondValue) - 1;
|
||||
}
|
||||
/**
|
||||
* Creates a Collection from a list of entries.
|
||||
*
|
||||
* @param entries - The list of entries
|
||||
* @param combine - Function to combine an existing entry with a new one
|
||||
* @example
|
||||
* ```ts
|
||||
* Collection.combineEntries([["a", 1], ["b", 2], ["a", 2]], (x, y) => x + y);
|
||||
* // returns Collection { "a" => 3, "b" => 2 }
|
||||
* ```
|
||||
*/
|
||||
static combineEntries(entries, combine) {
|
||||
const coll = new _Collection();
|
||||
for (const [key, value] of entries) {
|
||||
if (coll.has(key)) {
|
||||
coll.set(key, combine(coll.get(key), value, key));
|
||||
} else {
|
||||
coll.set(key, value);
|
||||
}
|
||||
}
|
||||
return coll;
|
||||
}
|
||||
};
|
||||
|
||||
// src/index.ts
|
||||
var version = "2.0.0";
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
Collection,
|
||||
version
|
||||
});
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@discordjs/rest/node_modules/@discordjs/collection/dist/index.js.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/node_modules/@discordjs/collection/dist/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
628
node_modules/@discordjs/rest/node_modules/@discordjs/collection/dist/index.mjs
generated
vendored
Normal file
628
node_modules/@discordjs/rest/node_modules/@discordjs/collection/dist/index.mjs
generated
vendored
Normal file
|
@ -0,0 +1,628 @@
|
|||
var __defProp = Object.defineProperty;
|
||||
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
||||
|
||||
// src/collection.ts
|
||||
var Collection = class _Collection extends Map {
|
||||
static {
|
||||
__name(this, "Collection");
|
||||
}
|
||||
/**
|
||||
* Obtains the value of the given key if it exists, otherwise sets and returns the value provided by the default value generator.
|
||||
*
|
||||
* @param key - The key to get if it exists, or set otherwise
|
||||
* @param defaultValueGenerator - A function that generates the default value
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.ensure(guildId, () => defaultGuildConfig);
|
||||
* ```
|
||||
*/
|
||||
ensure(key, defaultValueGenerator) {
|
||||
if (this.has(key))
|
||||
return this.get(key);
|
||||
if (typeof defaultValueGenerator !== "function")
|
||||
throw new TypeError(`${defaultValueGenerator} is not a function`);
|
||||
const defaultValue = defaultValueGenerator(key, this);
|
||||
this.set(key, defaultValue);
|
||||
return defaultValue;
|
||||
}
|
||||
/**
|
||||
* Checks if all of the elements exist in the collection.
|
||||
*
|
||||
* @param keys - The keys of the elements to check for
|
||||
* @returns `true` if all of the elements exist, `false` if at least one does not exist.
|
||||
*/
|
||||
hasAll(...keys) {
|
||||
return keys.every((key) => super.has(key));
|
||||
}
|
||||
/**
|
||||
* Checks if any of the elements exist in the collection.
|
||||
*
|
||||
* @param keys - The keys of the elements to check for
|
||||
* @returns `true` if any of the elements exist, `false` if none exist.
|
||||
*/
|
||||
hasAny(...keys) {
|
||||
return keys.some((key) => super.has(key));
|
||||
}
|
||||
first(amount) {
|
||||
if (amount === void 0)
|
||||
return this.values().next().value;
|
||||
if (amount < 0)
|
||||
return this.last(amount * -1);
|
||||
amount = Math.min(this.size, amount);
|
||||
const iter = this.values();
|
||||
return Array.from({ length: amount }, () => iter.next().value);
|
||||
}
|
||||
firstKey(amount) {
|
||||
if (amount === void 0)
|
||||
return this.keys().next().value;
|
||||
if (amount < 0)
|
||||
return this.lastKey(amount * -1);
|
||||
amount = Math.min(this.size, amount);
|
||||
const iter = this.keys();
|
||||
return Array.from({ length: amount }, () => iter.next().value);
|
||||
}
|
||||
last(amount) {
|
||||
const arr = [...this.values()];
|
||||
if (amount === void 0)
|
||||
return arr[arr.length - 1];
|
||||
if (amount < 0)
|
||||
return this.first(amount * -1);
|
||||
if (!amount)
|
||||
return [];
|
||||
return arr.slice(-amount);
|
||||
}
|
||||
lastKey(amount) {
|
||||
const arr = [...this.keys()];
|
||||
if (amount === void 0)
|
||||
return arr[arr.length - 1];
|
||||
if (amount < 0)
|
||||
return this.firstKey(amount * -1);
|
||||
if (!amount)
|
||||
return [];
|
||||
return arr.slice(-amount);
|
||||
}
|
||||
/**
|
||||
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.
|
||||
* Returns the item at a given index, allowing for positive and negative integers.
|
||||
* Negative integers count back from the last item in the collection.
|
||||
*
|
||||
* @param index - The index of the element to obtain
|
||||
*/
|
||||
at(index) {
|
||||
index = Math.floor(index);
|
||||
const arr = [...this.values()];
|
||||
return arr.at(index);
|
||||
}
|
||||
/**
|
||||
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.
|
||||
* Returns the key at a given index, allowing for positive and negative integers.
|
||||
* Negative integers count back from the last item in the collection.
|
||||
*
|
||||
* @param index - The index of the key to obtain
|
||||
*/
|
||||
keyAt(index) {
|
||||
index = Math.floor(index);
|
||||
const arr = [...this.keys()];
|
||||
return arr.at(index);
|
||||
}
|
||||
random(amount) {
|
||||
const arr = [...this.values()];
|
||||
if (amount === void 0)
|
||||
return arr[Math.floor(Math.random() * arr.length)];
|
||||
if (!arr.length || !amount)
|
||||
return [];
|
||||
return Array.from(
|
||||
{ length: Math.min(amount, arr.length) },
|
||||
() => arr.splice(Math.floor(Math.random() * arr.length), 1)[0]
|
||||
);
|
||||
}
|
||||
randomKey(amount) {
|
||||
const arr = [...this.keys()];
|
||||
if (amount === void 0)
|
||||
return arr[Math.floor(Math.random() * arr.length)];
|
||||
if (!arr.length || !amount)
|
||||
return [];
|
||||
return Array.from(
|
||||
{ length: Math.min(amount, arr.length) },
|
||||
() => arr.splice(Math.floor(Math.random() * arr.length), 1)[0]
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse | Array.reverse()}
|
||||
* but returns a Collection instead of an Array.
|
||||
*/
|
||||
reverse() {
|
||||
const entries = [...this.entries()].reverse();
|
||||
this.clear();
|
||||
for (const [key, value] of entries)
|
||||
this.set(key, value);
|
||||
return this;
|
||||
}
|
||||
find(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
for (const [key, val] of this) {
|
||||
if (fn(val, key, this))
|
||||
return val;
|
||||
}
|
||||
return void 0;
|
||||
}
|
||||
findKey(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
for (const [key, val] of this) {
|
||||
if (fn(val, key, this))
|
||||
return key;
|
||||
}
|
||||
return void 0;
|
||||
}
|
||||
findLast(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
const entries = [...this.entries()];
|
||||
for (let index = entries.length - 1; index >= 0; index--) {
|
||||
const val = entries[index][1];
|
||||
const key = entries[index][0];
|
||||
if (fn(val, key, this))
|
||||
return val;
|
||||
}
|
||||
return void 0;
|
||||
}
|
||||
findLastKey(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
const entries = [...this.entries()];
|
||||
for (let index = entries.length - 1; index >= 0; index--) {
|
||||
const key = entries[index][0];
|
||||
const val = entries[index][1];
|
||||
if (fn(val, key, this))
|
||||
return key;
|
||||
}
|
||||
return void 0;
|
||||
}
|
||||
sweep(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
const previousSize = this.size;
|
||||
for (const [key, val] of this) {
|
||||
if (fn(val, key, this))
|
||||
this.delete(key);
|
||||
}
|
||||
return previousSize - this.size;
|
||||
}
|
||||
filter(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
const results = new this.constructor[Symbol.species]();
|
||||
for (const [key, val] of this) {
|
||||
if (fn(val, key, this))
|
||||
results.set(key, val);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
partition(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
const results = [
|
||||
new this.constructor[Symbol.species](),
|
||||
new this.constructor[Symbol.species]()
|
||||
];
|
||||
for (const [key, val] of this) {
|
||||
if (fn(val, key, this)) {
|
||||
results[0].set(key, val);
|
||||
} else {
|
||||
results[1].set(key, val);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
flatMap(fn, thisArg) {
|
||||
const collections = this.map(fn, thisArg);
|
||||
return new this.constructor[Symbol.species]().concat(...collections);
|
||||
}
|
||||
map(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
const iter = this.entries();
|
||||
return Array.from({ length: this.size }, () => {
|
||||
const [key, value] = iter.next().value;
|
||||
return fn(value, key, this);
|
||||
});
|
||||
}
|
||||
mapValues(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
const coll = new this.constructor[Symbol.species]();
|
||||
for (const [key, val] of this)
|
||||
coll.set(key, fn(val, key, this));
|
||||
return coll;
|
||||
}
|
||||
some(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
for (const [key, val] of this) {
|
||||
if (fn(val, key, this))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
every(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
for (const [key, val] of this) {
|
||||
if (!fn(val, key, this))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Applies a function to produce a single value. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce | Array.reduce()}.
|
||||
*
|
||||
* @param fn - Function used to reduce, taking four arguments; `accumulator`, `currentValue`, `currentKey`,
|
||||
* and `collection`
|
||||
* @param initialValue - Starting value for the accumulator
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.reduce((acc, guild) => acc + guild.memberCount, 0);
|
||||
* ```
|
||||
*/
|
||||
reduce(fn, initialValue) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
let accumulator;
|
||||
const iterator = this.entries();
|
||||
if (initialValue === void 0) {
|
||||
if (this.size === 0)
|
||||
throw new TypeError("Reduce of empty collection with no initial value");
|
||||
accumulator = iterator.next().value[1];
|
||||
} else {
|
||||
accumulator = initialValue;
|
||||
}
|
||||
for (const [key, value] of iterator) {
|
||||
accumulator = fn(accumulator, value, key, this);
|
||||
}
|
||||
return accumulator;
|
||||
}
|
||||
/**
|
||||
* Applies a function to produce a single value. Identical in behavior to
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight | Array.reduceRight()}.
|
||||
*
|
||||
* @param fn - Function used to reduce, taking four arguments; `accumulator`, `value`, `key`, and `collection`
|
||||
* @param initialValue - Starting value for the accumulator
|
||||
*/
|
||||
reduceRight(fn, initialValue) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
const entries = [...this.entries()];
|
||||
let accumulator;
|
||||
let index;
|
||||
if (initialValue === void 0) {
|
||||
if (entries.length === 0)
|
||||
throw new TypeError("Reduce of empty collection with no initial value");
|
||||
accumulator = entries[entries.length - 1][1];
|
||||
index = entries.length - 1;
|
||||
} else {
|
||||
accumulator = initialValue;
|
||||
index = entries.length;
|
||||
}
|
||||
while (--index >= 0) {
|
||||
const key = entries[index][0];
|
||||
const val = entries[index][1];
|
||||
accumulator = fn(accumulator, val, key, this);
|
||||
}
|
||||
return accumulator;
|
||||
}
|
||||
each(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
for (const [key, value] of this) {
|
||||
fn(value, key, this);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
tap(fn, thisArg) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError(`${fn} is not a function`);
|
||||
if (thisArg !== void 0)
|
||||
fn = fn.bind(thisArg);
|
||||
fn(this);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Creates an identical shallow copy of this collection.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const newColl = someColl.clone();
|
||||
* ```
|
||||
*/
|
||||
clone() {
|
||||
return new this.constructor[Symbol.species](this);
|
||||
}
|
||||
/**
|
||||
* Combines this collection with others into a new collection. None of the source collections are modified.
|
||||
*
|
||||
* @param collections - Collections to merge
|
||||
* @example
|
||||
* ```ts
|
||||
* const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);
|
||||
* ```
|
||||
*/
|
||||
concat(...collections) {
|
||||
const newColl = this.clone();
|
||||
for (const coll of collections) {
|
||||
for (const [key, val] of coll)
|
||||
newColl.set(key, val);
|
||||
}
|
||||
return newColl;
|
||||
}
|
||||
/**
|
||||
* Checks if this collection shares identical items with another.
|
||||
* This is different to checking for equality using equal-signs, because
|
||||
* the collections may be different objects, but contain the same data.
|
||||
*
|
||||
* @param collection - Collection to compare with
|
||||
* @returns Whether the collections have identical contents
|
||||
*/
|
||||
equals(collection) {
|
||||
if (!collection)
|
||||
return false;
|
||||
if (this === collection)
|
||||
return true;
|
||||
if (this.size !== collection.size)
|
||||
return false;
|
||||
for (const [key, value] of this) {
|
||||
if (!collection.has(key) || value !== collection.get(key)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* The sort method sorts the items of a collection in place and returns it.
|
||||
* The sort is not necessarily stable in Node 10 or older.
|
||||
* The default sort order is according to string Unicode code points.
|
||||
*
|
||||
* @param compareFunction - Specifies a function that defines the sort order.
|
||||
* If omitted, the collection is sorted according to each character's Unicode code point value, according to the string conversion of each element.
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.sort((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
||||
* ```
|
||||
*/
|
||||
sort(compareFunction = _Collection.defaultSort) {
|
||||
const entries = [...this.entries()];
|
||||
entries.sort((a, b) => compareFunction(a[1], b[1], a[0], b[0]));
|
||||
super.clear();
|
||||
for (const [key, value] of entries) {
|
||||
super.set(key, value);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* The intersection method returns a new collection containing the items where the key is present in both collections.
|
||||
*
|
||||
* @param other - The other Collection to filter against
|
||||
* @example
|
||||
* ```ts
|
||||
* const col1 = new Collection([['a', 1], ['b', 2]]);
|
||||
* const col2 = new Collection([['a', 1], ['c', 3]]);
|
||||
* const intersection = col1.intersection(col2);
|
||||
* console.log(col1.intersection(col2));
|
||||
* // => Collection { 'a' => 1 }
|
||||
* ```
|
||||
*/
|
||||
intersection(other) {
|
||||
const coll = new this.constructor[Symbol.species]();
|
||||
for (const [key, value] of this) {
|
||||
if (other.has(key))
|
||||
coll.set(key, value);
|
||||
}
|
||||
return coll;
|
||||
}
|
||||
/**
|
||||
* Returns a new collection containing the items where the key is present in either of the collections.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* If the collections have any items with the same key, the value from the first collection will be used.
|
||||
* @param other - The other Collection to filter against
|
||||
* @example
|
||||
* ```ts
|
||||
* const col1 = new Collection([['a', 1], ['b', 2]]);
|
||||
* const col2 = new Collection([['a', 1], ['b', 3], ['c', 3]]);
|
||||
* const union = col1.union(col2);
|
||||
* console.log(union);
|
||||
* // => Collection { 'a' => 1, 'b' => 2, 'c' => 3 }
|
||||
* ```
|
||||
*/
|
||||
union(other) {
|
||||
const coll = new this.constructor[Symbol.species](this);
|
||||
for (const [key, value] of other) {
|
||||
if (!coll.has(key))
|
||||
coll.set(key, value);
|
||||
}
|
||||
return coll;
|
||||
}
|
||||
/**
|
||||
* Returns a new collection containing the items where the key is present in this collection but not the other.
|
||||
*
|
||||
* @param other - The other Collection to filter against
|
||||
* @example
|
||||
* ```ts
|
||||
* const col1 = new Collection([['a', 1], ['b', 2]]);
|
||||
* const col2 = new Collection([['a', 1], ['c', 3]]);
|
||||
* console.log(col1.difference(col2));
|
||||
* // => Collection { 'b' => 2 }
|
||||
* console.log(col2.difference(col1));
|
||||
* // => Collection { 'c' => 3 }
|
||||
* ```
|
||||
*/
|
||||
difference(other) {
|
||||
const coll = new this.constructor[Symbol.species]();
|
||||
for (const [key, value] of this) {
|
||||
if (!other.has(key))
|
||||
coll.set(key, value);
|
||||
}
|
||||
return coll;
|
||||
}
|
||||
/**
|
||||
* Returns a new collection containing only the items where the keys are present in either collection, but not both.
|
||||
*
|
||||
* @param other - The other Collection to filter against
|
||||
* @example
|
||||
* ```ts
|
||||
* const col1 = new Collection([['a', 1], ['b', 2]]);
|
||||
* const col2 = new Collection([['a', 1], ['c', 3]]);
|
||||
* const symmetricDifference = col1.symmetricDifference(col2);
|
||||
* console.log(col1.symmetricDifference(col2));
|
||||
* // => Collection { 'b' => 2, 'c' => 3 }
|
||||
* ```
|
||||
*/
|
||||
symmetricDifference(other) {
|
||||
const coll = new this.constructor[Symbol.species]();
|
||||
for (const [key, value] of this) {
|
||||
if (!other.has(key))
|
||||
coll.set(key, value);
|
||||
}
|
||||
for (const [key, value] of other) {
|
||||
if (!this.has(key))
|
||||
coll.set(key, value);
|
||||
}
|
||||
return coll;
|
||||
}
|
||||
/**
|
||||
* Merges two Collections together into a new Collection.
|
||||
*
|
||||
* @param other - The other Collection to merge with
|
||||
* @param whenInSelf - Function getting the result if the entry only exists in this Collection
|
||||
* @param whenInOther - Function getting the result if the entry only exists in the other Collection
|
||||
* @param whenInBoth - Function getting the result if the entry exists in both Collections
|
||||
* @example
|
||||
* ```ts
|
||||
* // Sums up the entries in two collections.
|
||||
* coll.merge(
|
||||
* other,
|
||||
* x => ({ keep: true, value: x }),
|
||||
* y => ({ keep: true, value: y }),
|
||||
* (x, y) => ({ keep: true, value: x + y }),
|
||||
* );
|
||||
* ```
|
||||
* @example
|
||||
* ```ts
|
||||
* // Intersects two collections in a left-biased manner.
|
||||
* coll.merge(
|
||||
* other,
|
||||
* x => ({ keep: false }),
|
||||
* y => ({ keep: false }),
|
||||
* (x, _) => ({ keep: true, value: x }),
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
merge(other, whenInSelf, whenInOther, whenInBoth) {
|
||||
const coll = new this.constructor[Symbol.species]();
|
||||
const keys = /* @__PURE__ */ new Set([...this.keys(), ...other.keys()]);
|
||||
for (const key of keys) {
|
||||
const hasInSelf = this.has(key);
|
||||
const hasInOther = other.has(key);
|
||||
if (hasInSelf && hasInOther) {
|
||||
const result = whenInBoth(this.get(key), other.get(key), key);
|
||||
if (result.keep)
|
||||
coll.set(key, result.value);
|
||||
} else if (hasInSelf) {
|
||||
const result = whenInSelf(this.get(key), key);
|
||||
if (result.keep)
|
||||
coll.set(key, result.value);
|
||||
} else if (hasInOther) {
|
||||
const result = whenInOther(other.get(key), key);
|
||||
if (result.keep)
|
||||
coll.set(key, result.value);
|
||||
}
|
||||
}
|
||||
return coll;
|
||||
}
|
||||
/**
|
||||
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toReversed | Array.toReversed()}
|
||||
* but returns a Collection instead of an Array.
|
||||
*/
|
||||
toReversed() {
|
||||
return new this.constructor[Symbol.species](this).reverse();
|
||||
}
|
||||
/**
|
||||
* The sorted method sorts the items of a collection and returns it.
|
||||
* The sort is not necessarily stable in Node 10 or older.
|
||||
* The default sort order is according to string Unicode code points.
|
||||
*
|
||||
* @param compareFunction - Specifies a function that defines the sort order.
|
||||
* If omitted, the collection is sorted according to each character's Unicode code point value,
|
||||
* according to the string conversion of each element.
|
||||
* @example
|
||||
* ```ts
|
||||
* collection.sorted((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
||||
* ```
|
||||
*/
|
||||
toSorted(compareFunction = _Collection.defaultSort) {
|
||||
return new this.constructor[Symbol.species](this).sort((av, bv, ak, bk) => compareFunction(av, bv, ak, bk));
|
||||
}
|
||||
toJSON() {
|
||||
return [...this.entries()];
|
||||
}
|
||||
static defaultSort(firstValue, secondValue) {
|
||||
return Number(firstValue > secondValue) || Number(firstValue === secondValue) - 1;
|
||||
}
|
||||
/**
|
||||
* Creates a Collection from a list of entries.
|
||||
*
|
||||
* @param entries - The list of entries
|
||||
* @param combine - Function to combine an existing entry with a new one
|
||||
* @example
|
||||
* ```ts
|
||||
* Collection.combineEntries([["a", 1], ["b", 2], ["a", 2]], (x, y) => x + y);
|
||||
* // returns Collection { "a" => 3, "b" => 2 }
|
||||
* ```
|
||||
*/
|
||||
static combineEntries(entries, combine) {
|
||||
const coll = new _Collection();
|
||||
for (const [key, value] of entries) {
|
||||
if (coll.has(key)) {
|
||||
coll.set(key, combine(coll.get(key), value, key));
|
||||
} else {
|
||||
coll.set(key, value);
|
||||
}
|
||||
}
|
||||
return coll;
|
||||
}
|
||||
};
|
||||
|
||||
// src/index.ts
|
||||
var version = "2.0.0";
|
||||
export {
|
||||
Collection,
|
||||
version
|
||||
};
|
||||
//# sourceMappingURL=index.mjs.map
|
1
node_modules/@discordjs/rest/node_modules/@discordjs/collection/dist/index.mjs.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/node_modules/@discordjs/collection/dist/index.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
83
node_modules/@discordjs/rest/node_modules/@discordjs/collection/package.json
generated
vendored
Normal file
83
node_modules/@discordjs/rest/node_modules/@discordjs/collection/package.json
generated
vendored
Normal file
|
@ -0,0 +1,83 @@
|
|||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "@discordjs/collection",
|
||||
"version": "2.0.0",
|
||||
"description": "Utility data structure used in discord.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"require": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"import": {
|
||||
"types": "./dist/index.d.mts",
|
||||
"default": "./dist/index.mjs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
"directories": {
|
||||
"lib": "src",
|
||||
"test": "__tests__"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"contributors": [
|
||||
"Crawl <icrawltogo@gmail.com>",
|
||||
"Amish Shah <amishshah.2k@gmail.com>",
|
||||
"SpaceEEC <spaceeec@yahoo.com>",
|
||||
"Vlad Frangu <kingdgrizzle@gmail.com>",
|
||||
"Aura Román <kyradiscord@gmail.com>"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"keywords": [
|
||||
"map",
|
||||
"collection",
|
||||
"utility"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/discordjs/discord.js.git",
|
||||
"directory": "packages/collection"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/discordjs/discord.js/issues"
|
||||
},
|
||||
"homepage": "https://discord.js.org",
|
||||
"devDependencies": {
|
||||
"@favware/cliff-jumper": "^2.2.1",
|
||||
"@types/node": "18.18.8",
|
||||
"@vitest/coverage-v8": "^0.34.6",
|
||||
"cross-env": "^7.0.3",
|
||||
"esbuild-plugin-version-injector": "^1.2.1",
|
||||
"eslint": "^8.53.0",
|
||||
"eslint-config-neon": "^0.1.57",
|
||||
"eslint-formatter-pretty": "^5.0.0",
|
||||
"prettier": "^3.0.3",
|
||||
"tsup": "^7.2.0",
|
||||
"turbo": "^1.10.17-canary.0",
|
||||
"typescript": "^5.2.2",
|
||||
"vitest": "^0.34.6",
|
||||
"@discordjs/api-extractor": "^7.38.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "vitest run",
|
||||
"build": "tsc --noEmit && tsup",
|
||||
"build:docs": "tsc -p tsconfig.docs.json",
|
||||
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
|
||||
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
|
||||
"fmt": "pnpm run format",
|
||||
"docs": "pnpm run build:docs && api-extractor run --local",
|
||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/collection/*'",
|
||||
"release": "cliff-jumper"
|
||||
}
|
||||
}
|
116
node_modules/@discordjs/rest/package.json
generated
vendored
Normal file
116
node_modules/@discordjs/rest/package.json
generated
vendored
Normal file
|
@ -0,0 +1,116 @@
|
|||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "@discordjs/rest",
|
||||
"version": "2.2.0",
|
||||
"description": "The REST API for discord.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"node": {
|
||||
"require": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"import": {
|
||||
"types": "./dist/index.d.mts",
|
||||
"default": "./dist/index.mjs"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"require": {
|
||||
"types": "./dist/web.d.ts",
|
||||
"default": "./dist/web.js"
|
||||
},
|
||||
"import": {
|
||||
"types": "./dist/web.d.mts",
|
||||
"default": "./dist/web.mjs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"./*": {
|
||||
"require": {
|
||||
"types": "./dist/strategies/*.d.ts",
|
||||
"default": "./dist/strategies/*.js"
|
||||
},
|
||||
"import": {
|
||||
"types": "./dist/strategies/*.d.mts",
|
||||
"default": "./dist/strategies/*.mjs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"types": "./dist/index.d.ts",
|
||||
"directories": {
|
||||
"lib": "src",
|
||||
"test": "__tests__"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"contributors": [
|
||||
"Crawl <icrawltogo@gmail.com>",
|
||||
"Amish Shah <amishshah.2k@gmail.com>",
|
||||
"SpaceEEC <spaceeec@yahoo.com>",
|
||||
"Vlad Frangu <kingdgrizzle@gmail.com>",
|
||||
"Aura Román <kyradiscord@gmail.com>"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"keywords": [
|
||||
"discord",
|
||||
"api",
|
||||
"rest",
|
||||
"discordapp",
|
||||
"discordjs"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/discordjs/discord.js.git",
|
||||
"directory": "packages/rest"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/discordjs/discord.js/issues"
|
||||
},
|
||||
"homepage": "https://discord.js.org",
|
||||
"dependencies": {
|
||||
"@sapphire/async-queue": "^1.5.0",
|
||||
"@sapphire/snowflake": "^3.5.1",
|
||||
"@vladfrangu/async_event_emitter": "^2.2.2",
|
||||
"discord-api-types": "0.37.61",
|
||||
"magic-bytes.js": "^1.5.0",
|
||||
"tslib": "^2.6.2",
|
||||
"undici": "5.27.2",
|
||||
"@discordjs/util": "^1.0.2",
|
||||
"@discordjs/collection": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@favware/cliff-jumper": "^2.2.1",
|
||||
"@types/node": "18.17.9",
|
||||
"@vitest/coverage-v8": "^0.34.6",
|
||||
"cross-env": "^7.0.3",
|
||||
"esbuild-plugin-version-injector": "^1.2.1",
|
||||
"eslint": "^8.53.0",
|
||||
"eslint-config-neon": "^0.1.57",
|
||||
"eslint-formatter-pretty": "^5.0.0",
|
||||
"prettier": "^3.1.0",
|
||||
"tsup": "^7.2.0",
|
||||
"turbo": "^1.10.17-canary.0",
|
||||
"typescript": "^5.2.2",
|
||||
"vitest": "^0.34.6",
|
||||
"@discordjs/api-extractor": "^7.38.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.11.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "vitest run",
|
||||
"build": "tsc --noEmit && tsup",
|
||||
"build:docs": "tsc -p tsconfig.docs.json",
|
||||
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
|
||||
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
|
||||
"fmt": "pnpm run format",
|
||||
"docs": "pnpm run build:docs && api-extractor run --local --minify",
|
||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/rest/*'",
|
||||
"release": "cliff-jumper"
|
||||
}
|
||||
}
|
190
node_modules/@discordjs/util/LICENSE
generated
vendored
Normal file
190
node_modules/@discordjs/util/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,190 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Copyright 2022 Noel Buechler
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
65
node_modules/@discordjs/util/README.md
generated
vendored
Normal file
65
node_modules/@discordjs/util/README.md
generated
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
<div align="center">
|
||||
<br />
|
||||
<p>
|
||||
<a href="https://discord.js.org"><img src="https://discord.js.org/static/logo.svg" width="546" alt="discord.js" /></a>
|
||||
</p>
|
||||
<br />
|
||||
<p>
|
||||
<a href="https://discord.gg/djs"><img src="https://img.shields.io/discord/222078108977594368?color=5865F2&logo=discord&logoColor=white" alt="Discord server" /></a>
|
||||
<a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Build status" /></a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
|
||||
<a href="https://www.cloudflare.com"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-workers.png" alt="Cloudflare Workers" height="44" /></a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
## About
|
||||
|
||||
`@discordjs/util` is a collection of utility functions for use with discord.js.
|
||||
|
||||
## Installation
|
||||
|
||||
**Node.js 16.11.0 or newer is required.**
|
||||
|
||||
```sh
|
||||
npm install @discordjs/util
|
||||
yarn add @discordjs/util
|
||||
pnpm add @discordjs/util
|
||||
bun add @discordjs/util
|
||||
```
|
||||
|
||||
## Links
|
||||
|
||||
- [Website][website] ([source][website-source])
|
||||
- [Documentation][documentation]
|
||||
- [Guide][guide] ([source][guide-source])
|
||||
Also see the v13 to v14 [Update Guide][guide-update], which includes updated and removed items from the library.
|
||||
- [discord.js Discord server][discord]
|
||||
- [Discord API Discord server][discord-api]
|
||||
- [GitHub][source]
|
||||
- [npm][npm]
|
||||
- [Related libraries][related-libs]
|
||||
|
||||
## Contributing
|
||||
|
||||
Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the
|
||||
[documentation][documentation].
|
||||
See [the contribution guide][contributing] if you'd like to submit a PR.
|
||||
|
||||
## Help
|
||||
|
||||
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to join our official [discord.js Server][discord].
|
||||
|
||||
[website]: https://discord.js.org
|
||||
[website-source]: https://github.com/discordjs/discord.js/tree/main/apps/website
|
||||
[documentation]: https://discord.js.org/docs/packages/util/stable
|
||||
[guide]: https://discordjs.guide/
|
||||
[guide-source]: https://github.com/discordjs/guide
|
||||
[guide-update]: https://discordjs.guide/additional-info/changes-in-v14.html
|
||||
[discord]: https://discord.gg/djs
|
||||
[discord-api]: https://discord.gg/discord-api
|
||||
[source]: https://github.com/discordjs/discord.js/tree/main/packages/util
|
||||
[npm]: https://www.npmjs.com/package/@discordjs/util
|
||||
[related-libs]: https://discord.com/developers/docs/topics/community-resources#libraries
|
||||
[contributing]: https://github.com/discordjs/discord.js/blob/main/.github/CONTRIBUTING.md
|
117
node_modules/@discordjs/util/dist/index.d.mts
generated
vendored
Normal file
117
node_modules/@discordjs/util/dist/index.d.mts
generated
vendored
Normal file
|
@ -0,0 +1,117 @@
|
|||
/**
|
||||
* Represents a type that may or may not be a promise
|
||||
*/
|
||||
type Awaitable<Value> = PromiseLike<Value> | Value;
|
||||
|
||||
/**
|
||||
* Lazy is a wrapper around a value that is computed lazily. It is useful for
|
||||
* cases where the value is expensive to compute and the computation may not
|
||||
* be needed at all.
|
||||
*
|
||||
* @param cb - The callback to lazily evaluate
|
||||
* @typeParam Value - The type of the value
|
||||
* @example
|
||||
* ```ts
|
||||
* const value = lazy(() => computeExpensiveValue());
|
||||
* ```
|
||||
*/
|
||||
declare function lazy<Value>(cb: () => Value): () => Value;
|
||||
|
||||
/**
|
||||
* Options for creating a range
|
||||
*/
|
||||
interface RangeOptions {
|
||||
/**
|
||||
* The end of the range (exclusive)
|
||||
*/
|
||||
end: number;
|
||||
/**
|
||||
* The start of the range (inclusive)
|
||||
*/
|
||||
start: number;
|
||||
/**
|
||||
* The amount to increment by
|
||||
*
|
||||
* @defaultValue `1`
|
||||
*/
|
||||
step?: number;
|
||||
}
|
||||
/**
|
||||
* A generator to yield numbers in a given range
|
||||
*
|
||||
* @remarks
|
||||
* This method is end-exclusive, for example the last number yielded by `range(5)` is 4. If you
|
||||
* prefer for the end to be included add 1 to the range or `end` option.
|
||||
* @param range - A number representing the the range to yield (exclusive) or an object with start, end and step
|
||||
* @example
|
||||
* Basic range
|
||||
* ```ts
|
||||
* for (const number of range(5)) {
|
||||
* console.log(number);
|
||||
* }
|
||||
* // Prints 0, 1, 2, 3, 4
|
||||
* ```
|
||||
* @example
|
||||
* Range with a step
|
||||
* ```ts
|
||||
* for (const number of range({ start: 3, end: 10, step: 2 })) {
|
||||
* console.log(number);
|
||||
* }
|
||||
* // Prints 3, 5, 7, 9
|
||||
* ```
|
||||
*/
|
||||
declare function range(range: RangeOptions | number): Generator<number, void, unknown>;
|
||||
|
||||
/**
|
||||
* Calculates the shard id for a given guild id.
|
||||
*
|
||||
* @param guildId - The guild id to calculate the shard id for
|
||||
* @param shardCount - The total number of shards
|
||||
*/
|
||||
declare function calculateShardId(guildId: string, shardCount: number): number;
|
||||
|
||||
declare function shouldUseGlobalFetchAndWebSocket(): boolean;
|
||||
|
||||
/**
|
||||
* Resolves the user agent appendix string for the current environment.
|
||||
*/
|
||||
declare function getUserAgentAppendix(): string;
|
||||
|
||||
/**
|
||||
* Represents an object capable of representing itself as a JSON object
|
||||
*
|
||||
* @typeParam Value - The JSON type corresponding to {@link JSONEncodable.toJSON} outputs.
|
||||
*/
|
||||
interface JSONEncodable<Value> {
|
||||
/**
|
||||
* Transforms this object to its JSON format
|
||||
*/
|
||||
toJSON(): Value;
|
||||
}
|
||||
/**
|
||||
* Indicates if an object is encodable or not.
|
||||
*
|
||||
* @param maybeEncodable - The object to check against
|
||||
*/
|
||||
declare function isJSONEncodable(maybeEncodable: unknown): maybeEncodable is JSONEncodable<unknown>;
|
||||
|
||||
/**
|
||||
* Represents a structure that can be checked against another
|
||||
* given structure for equality
|
||||
*
|
||||
* @typeParam Value - The type of object to compare the current object to
|
||||
*/
|
||||
interface Equatable<Value> {
|
||||
/**
|
||||
* Whether or not this is equal to another structure
|
||||
*/
|
||||
equals(other: Value): boolean;
|
||||
}
|
||||
/**
|
||||
* Indicates if an object is equatable or not.
|
||||
*
|
||||
* @param maybeEquatable - The object to check against
|
||||
*/
|
||||
declare function isEquatable(maybeEquatable: unknown): maybeEquatable is Equatable<unknown>;
|
||||
|
||||
export { Awaitable, Equatable, JSONEncodable, RangeOptions, calculateShardId, getUserAgentAppendix, isEquatable, isJSONEncodable, lazy, range, shouldUseGlobalFetchAndWebSocket };
|
117
node_modules/@discordjs/util/dist/index.d.ts
generated
vendored
Normal file
117
node_modules/@discordjs/util/dist/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,117 @@
|
|||
/**
|
||||
* Represents a type that may or may not be a promise
|
||||
*/
|
||||
type Awaitable<Value> = PromiseLike<Value> | Value;
|
||||
|
||||
/**
|
||||
* Lazy is a wrapper around a value that is computed lazily. It is useful for
|
||||
* cases where the value is expensive to compute and the computation may not
|
||||
* be needed at all.
|
||||
*
|
||||
* @param cb - The callback to lazily evaluate
|
||||
* @typeParam Value - The type of the value
|
||||
* @example
|
||||
* ```ts
|
||||
* const value = lazy(() => computeExpensiveValue());
|
||||
* ```
|
||||
*/
|
||||
declare function lazy<Value>(cb: () => Value): () => Value;
|
||||
|
||||
/**
|
||||
* Options for creating a range
|
||||
*/
|
||||
interface RangeOptions {
|
||||
/**
|
||||
* The end of the range (exclusive)
|
||||
*/
|
||||
end: number;
|
||||
/**
|
||||
* The start of the range (inclusive)
|
||||
*/
|
||||
start: number;
|
||||
/**
|
||||
* The amount to increment by
|
||||
*
|
||||
* @defaultValue `1`
|
||||
*/
|
||||
step?: number;
|
||||
}
|
||||
/**
|
||||
* A generator to yield numbers in a given range
|
||||
*
|
||||
* @remarks
|
||||
* This method is end-exclusive, for example the last number yielded by `range(5)` is 4. If you
|
||||
* prefer for the end to be included add 1 to the range or `end` option.
|
||||
* @param range - A number representing the the range to yield (exclusive) or an object with start, end and step
|
||||
* @example
|
||||
* Basic range
|
||||
* ```ts
|
||||
* for (const number of range(5)) {
|
||||
* console.log(number);
|
||||
* }
|
||||
* // Prints 0, 1, 2, 3, 4
|
||||
* ```
|
||||
* @example
|
||||
* Range with a step
|
||||
* ```ts
|
||||
* for (const number of range({ start: 3, end: 10, step: 2 })) {
|
||||
* console.log(number);
|
||||
* }
|
||||
* // Prints 3, 5, 7, 9
|
||||
* ```
|
||||
*/
|
||||
declare function range(range: RangeOptions | number): Generator<number, void, unknown>;
|
||||
|
||||
/**
|
||||
* Calculates the shard id for a given guild id.
|
||||
*
|
||||
* @param guildId - The guild id to calculate the shard id for
|
||||
* @param shardCount - The total number of shards
|
||||
*/
|
||||
declare function calculateShardId(guildId: string, shardCount: number): number;
|
||||
|
||||
declare function shouldUseGlobalFetchAndWebSocket(): boolean;
|
||||
|
||||
/**
|
||||
* Resolves the user agent appendix string for the current environment.
|
||||
*/
|
||||
declare function getUserAgentAppendix(): string;
|
||||
|
||||
/**
|
||||
* Represents an object capable of representing itself as a JSON object
|
||||
*
|
||||
* @typeParam Value - The JSON type corresponding to {@link JSONEncodable.toJSON} outputs.
|
||||
*/
|
||||
interface JSONEncodable<Value> {
|
||||
/**
|
||||
* Transforms this object to its JSON format
|
||||
*/
|
||||
toJSON(): Value;
|
||||
}
|
||||
/**
|
||||
* Indicates if an object is encodable or not.
|
||||
*
|
||||
* @param maybeEncodable - The object to check against
|
||||
*/
|
||||
declare function isJSONEncodable(maybeEncodable: unknown): maybeEncodable is JSONEncodable<unknown>;
|
||||
|
||||
/**
|
||||
* Represents a structure that can be checked against another
|
||||
* given structure for equality
|
||||
*
|
||||
* @typeParam Value - The type of object to compare the current object to
|
||||
*/
|
||||
interface Equatable<Value> {
|
||||
/**
|
||||
* Whether or not this is equal to another structure
|
||||
*/
|
||||
equals(other: Value): boolean;
|
||||
}
|
||||
/**
|
||||
* Indicates if an object is equatable or not.
|
||||
*
|
||||
* @param maybeEquatable - The object to check against
|
||||
*/
|
||||
declare function isEquatable(maybeEquatable: unknown): maybeEquatable is Equatable<unknown>;
|
||||
|
||||
export { Awaitable, Equatable, JSONEncodable, RangeOptions, calculateShardId, getUserAgentAppendix, isEquatable, isJSONEncodable, lazy, range, shouldUseGlobalFetchAndWebSocket };
|
130
node_modules/@discordjs/util/dist/index.js
generated
vendored
Normal file
130
node_modules/@discordjs/util/dist/index.js
generated
vendored
Normal file
|
@ -0,0 +1,130 @@
|
|||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/index.ts
|
||||
var src_exports = {};
|
||||
__export(src_exports, {
|
||||
calculateShardId: () => calculateShardId,
|
||||
getUserAgentAppendix: () => getUserAgentAppendix,
|
||||
isEquatable: () => isEquatable,
|
||||
isJSONEncodable: () => isJSONEncodable,
|
||||
lazy: () => lazy,
|
||||
range: () => range,
|
||||
shouldUseGlobalFetchAndWebSocket: () => shouldUseGlobalFetchAndWebSocket
|
||||
});
|
||||
module.exports = __toCommonJS(src_exports);
|
||||
|
||||
// src/functions/lazy.ts
|
||||
function lazy(cb) {
|
||||
let defaultValue;
|
||||
return () => defaultValue ??= cb();
|
||||
}
|
||||
__name(lazy, "lazy");
|
||||
|
||||
// src/functions/range.ts
|
||||
function* range(range2) {
|
||||
let rangeEnd;
|
||||
let start = 0;
|
||||
let step = 1;
|
||||
if (typeof range2 === "number") {
|
||||
rangeEnd = range2;
|
||||
} else {
|
||||
start = range2.start;
|
||||
rangeEnd = range2.end;
|
||||
step = range2.step ?? 1;
|
||||
}
|
||||
for (let index = start; index < rangeEnd; index += step) {
|
||||
yield index;
|
||||
}
|
||||
}
|
||||
__name(range, "range");
|
||||
|
||||
// src/functions/calculateShardId.ts
|
||||
function calculateShardId(guildId, shardCount) {
|
||||
return Number(BigInt(guildId) >> 22n) % shardCount;
|
||||
}
|
||||
__name(calculateShardId, "calculateShardId");
|
||||
|
||||
// src/functions/runtime.ts
|
||||
function shouldUseGlobalFetchAndWebSocket() {
|
||||
if (typeof globalThis.process === "undefined") {
|
||||
return "fetch" in globalThis && "WebSocket" in globalThis;
|
||||
}
|
||||
if ("versions" in globalThis.process) {
|
||||
return "deno" in globalThis.process.versions || "bun" in globalThis.process.versions;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
__name(shouldUseGlobalFetchAndWebSocket, "shouldUseGlobalFetchAndWebSocket");
|
||||
|
||||
// src/functions/userAgentAppendix.ts
|
||||
function getUserAgentAppendix() {
|
||||
if (typeof globalThis.EdgeRuntime !== "undefined") {
|
||||
return "Vercel-Edge-Functions";
|
||||
}
|
||||
if (typeof globalThis.R2 !== "undefined" && typeof globalThis.WebSocketPair !== "undefined") {
|
||||
return "Cloudflare-Workers";
|
||||
}
|
||||
if (typeof globalThis.Netlify !== "undefined") {
|
||||
return "Netlify-Edge-Functions";
|
||||
}
|
||||
if (typeof globalThis.process !== "object") {
|
||||
if (typeof globalThis.navigator === "object") {
|
||||
return globalThis.navigator.userAgent;
|
||||
}
|
||||
return "UnknownEnvironment";
|
||||
}
|
||||
if ("versions" in globalThis.process) {
|
||||
if ("deno" in globalThis.process.versions) {
|
||||
return `Deno/${globalThis.process.versions.deno}`;
|
||||
}
|
||||
if ("bun" in globalThis.process.versions) {
|
||||
return `Bun/${globalThis.process.versions.bun}`;
|
||||
}
|
||||
if ("node" in globalThis.process.versions) {
|
||||
return `Node.js/${globalThis.process.versions.node}`;
|
||||
}
|
||||
}
|
||||
return "UnknownEnvironment";
|
||||
}
|
||||
__name(getUserAgentAppendix, "getUserAgentAppendix");
|
||||
|
||||
// src/JSONEncodable.ts
|
||||
function isJSONEncodable(maybeEncodable) {
|
||||
return maybeEncodable !== null && typeof maybeEncodable === "object" && "toJSON" in maybeEncodable;
|
||||
}
|
||||
__name(isJSONEncodable, "isJSONEncodable");
|
||||
|
||||
// src/Equatable.ts
|
||||
function isEquatable(maybeEquatable) {
|
||||
return maybeEquatable !== null && typeof maybeEquatable === "object" && "equals" in maybeEquatable;
|
||||
}
|
||||
__name(isEquatable, "isEquatable");
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
calculateShardId,
|
||||
getUserAgentAppendix,
|
||||
isEquatable,
|
||||
isJSONEncodable,
|
||||
lazy,
|
||||
range,
|
||||
shouldUseGlobalFetchAndWebSocket
|
||||
});
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@discordjs/util/dist/index.js.map
generated
vendored
Normal file
1
node_modules/@discordjs/util/dist/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
99
node_modules/@discordjs/util/dist/index.mjs
generated
vendored
Normal file
99
node_modules/@discordjs/util/dist/index.mjs
generated
vendored
Normal file
|
@ -0,0 +1,99 @@
|
|||
var __defProp = Object.defineProperty;
|
||||
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
||||
|
||||
// src/functions/lazy.ts
|
||||
function lazy(cb) {
|
||||
let defaultValue;
|
||||
return () => defaultValue ??= cb();
|
||||
}
|
||||
__name(lazy, "lazy");
|
||||
|
||||
// src/functions/range.ts
|
||||
function* range(range2) {
|
||||
let rangeEnd;
|
||||
let start = 0;
|
||||
let step = 1;
|
||||
if (typeof range2 === "number") {
|
||||
rangeEnd = range2;
|
||||
} else {
|
||||
start = range2.start;
|
||||
rangeEnd = range2.end;
|
||||
step = range2.step ?? 1;
|
||||
}
|
||||
for (let index = start; index < rangeEnd; index += step) {
|
||||
yield index;
|
||||
}
|
||||
}
|
||||
__name(range, "range");
|
||||
|
||||
// src/functions/calculateShardId.ts
|
||||
function calculateShardId(guildId, shardCount) {
|
||||
return Number(BigInt(guildId) >> 22n) % shardCount;
|
||||
}
|
||||
__name(calculateShardId, "calculateShardId");
|
||||
|
||||
// src/functions/runtime.ts
|
||||
function shouldUseGlobalFetchAndWebSocket() {
|
||||
if (typeof globalThis.process === "undefined") {
|
||||
return "fetch" in globalThis && "WebSocket" in globalThis;
|
||||
}
|
||||
if ("versions" in globalThis.process) {
|
||||
return "deno" in globalThis.process.versions || "bun" in globalThis.process.versions;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
__name(shouldUseGlobalFetchAndWebSocket, "shouldUseGlobalFetchAndWebSocket");
|
||||
|
||||
// src/functions/userAgentAppendix.ts
|
||||
function getUserAgentAppendix() {
|
||||
if (typeof globalThis.EdgeRuntime !== "undefined") {
|
||||
return "Vercel-Edge-Functions";
|
||||
}
|
||||
if (typeof globalThis.R2 !== "undefined" && typeof globalThis.WebSocketPair !== "undefined") {
|
||||
return "Cloudflare-Workers";
|
||||
}
|
||||
if (typeof globalThis.Netlify !== "undefined") {
|
||||
return "Netlify-Edge-Functions";
|
||||
}
|
||||
if (typeof globalThis.process !== "object") {
|
||||
if (typeof globalThis.navigator === "object") {
|
||||
return globalThis.navigator.userAgent;
|
||||
}
|
||||
return "UnknownEnvironment";
|
||||
}
|
||||
if ("versions" in globalThis.process) {
|
||||
if ("deno" in globalThis.process.versions) {
|
||||
return `Deno/${globalThis.process.versions.deno}`;
|
||||
}
|
||||
if ("bun" in globalThis.process.versions) {
|
||||
return `Bun/${globalThis.process.versions.bun}`;
|
||||
}
|
||||
if ("node" in globalThis.process.versions) {
|
||||
return `Node.js/${globalThis.process.versions.node}`;
|
||||
}
|
||||
}
|
||||
return "UnknownEnvironment";
|
||||
}
|
||||
__name(getUserAgentAppendix, "getUserAgentAppendix");
|
||||
|
||||
// src/JSONEncodable.ts
|
||||
function isJSONEncodable(maybeEncodable) {
|
||||
return maybeEncodable !== null && typeof maybeEncodable === "object" && "toJSON" in maybeEncodable;
|
||||
}
|
||||
__name(isJSONEncodable, "isJSONEncodable");
|
||||
|
||||
// src/Equatable.ts
|
||||
function isEquatable(maybeEquatable) {
|
||||
return maybeEquatable !== null && typeof maybeEquatable === "object" && "equals" in maybeEquatable;
|
||||
}
|
||||
__name(isEquatable, "isEquatable");
|
||||
export {
|
||||
calculateShardId,
|
||||
getUserAgentAppendix,
|
||||
isEquatable,
|
||||
isJSONEncodable,
|
||||
lazy,
|
||||
range,
|
||||
shouldUseGlobalFetchAndWebSocket
|
||||
};
|
||||
//# sourceMappingURL=index.mjs.map
|
1
node_modules/@discordjs/util/dist/index.mjs.map
generated
vendored
Normal file
1
node_modules/@discordjs/util/dist/index.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
87
node_modules/@discordjs/util/package.json
generated
vendored
Normal file
87
node_modules/@discordjs/util/package.json
generated
vendored
Normal file
|
@ -0,0 +1,87 @@
|
|||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "@discordjs/util",
|
||||
"version": "1.0.2",
|
||||
"description": "Utilities shared across Discord.js packages",
|
||||
"exports": {
|
||||
".": {
|
||||
"require": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"import": {
|
||||
"types": "./dist/index.d.mts",
|
||||
"default": "./dist/index.mjs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
"directories": {
|
||||
"lib": "src"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"contributors": [
|
||||
"Crawl <icrawltogo@gmail.com>",
|
||||
"Amish Shah <amishshah.2k@gmail.com>",
|
||||
"Vlad Frangu <kingdgrizzle@gmail.com>",
|
||||
"SpaceEEC <spaceeec@yahoo.com>",
|
||||
"Aura Román <kyradiscord@gmail.com>"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"keywords": [
|
||||
"api",
|
||||
"bot",
|
||||
"client",
|
||||
"node",
|
||||
"discordjs"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/discordjs/discord.js.git",
|
||||
"directory": "packages/util"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/discordjs/discord.js/issues"
|
||||
},
|
||||
"homepage": "https://discord.js.org",
|
||||
"devDependencies": {
|
||||
"@favware/cliff-jumper": "^2.2.1",
|
||||
"@types/node": "16.18.60",
|
||||
"@vitest/coverage-v8": "^0.34.6",
|
||||
"cross-env": "^7.0.3",
|
||||
"eslint": "^8.53.0",
|
||||
"eslint-config-neon": "^0.1.57",
|
||||
"eslint-formatter-pretty": "^5.0.0",
|
||||
"prettier": "^3.0.3",
|
||||
"tsd": "^0.29.0",
|
||||
"tsup": "^7.2.0",
|
||||
"turbo": "^1.10.17-canary.0",
|
||||
"typescript": "^5.2.2",
|
||||
"vitest": "^0.34.6",
|
||||
"@discordjs/api-extractor": "^7.38.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.11.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"tsd": {
|
||||
"directory": "__tests__/types"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc --noEmit && tsup",
|
||||
"build:docs": "tsc -p tsconfig.docs.json",
|
||||
"test": "vitest run && tsd",
|
||||
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src",
|
||||
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src",
|
||||
"fmt": "pnpm run format",
|
||||
"docs": "pnpm run build:docs && api-extractor run --local",
|
||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/util/*'",
|
||||
"release": "cliff-jumper"
|
||||
}
|
||||
}
|
191
node_modules/@discordjs/ws/LICENSE
generated
vendored
Normal file
191
node_modules/@discordjs/ws/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,191 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Copyright 2022 Noel Buechler
|
||||
Copyright 2022 Denis Cristea
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue