style: format (#2925)

This commit is contained in:
ITOH
2023-04-01 02:46:46 +02:00
committed by GitHub
parent 4d3a2f7665
commit 05fc3fbeba
85 changed files with 670 additions and 828 deletions

View File

@@ -17,11 +17,7 @@
// Configure properties specific to VS Code.
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"TabNine.tabnine-vscode"
]
"extensions": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode", "TabNine.tabnine-vscode"]
}
},
@@ -32,5 +28,5 @@
// "postCreateCommand": "yarn install",
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "node",
"remoteUser": "node"
}

View File

@@ -1,7 +1,5 @@
{
"root": true,
// This tells ESLint to load the config from the package `eslint-config-custom`
"extends": [
"discordeno"
]
"extends": ["discordeno"]
}

View File

@@ -18,7 +18,7 @@ jobs:
node-version: 18
- uses: denoland/setup-deno@main
with:
deno-version: "v1.29"
deno-version: 'v1.29'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT

View File

@@ -18,14 +18,14 @@ jobs:
strategy:
fail-fast: false
matrix:
package: ["gateway", "rest", "types", "utils", "bot"]
package: ['gateway', 'rest', 'types', 'utils', 'bot']
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: "https://registry.npmjs.org"
scope: "@discordeno"
registry-url: 'https://registry.npmjs.org'
scope: '@discordeno'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT

View File

@@ -6,23 +6,23 @@ name: Deploy Docs Site
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: ["main"]
branches: ['main']
paths:
- "website/**"
- ".github/workflows/site.yml"
- "jsdoc2md.json"
- "typedoc.json"
- "package.json"
- "packages/**"
- 'website/**'
- '.github/workflows/site.yml'
- 'jsdoc2md.json'
- 'typedoc.json'
- 'package.json'
- 'packages/**'
pull_request:
branches: ["main"]
branches: ['main']
paths:
- "website/**"
- ".github/workflows/site.yml"
- "jsdoc2md.json"
- "typedoc.json"
- "package.json"
- "packages/**"
- 'website/**'
- '.github/workflows/site.yml'
- 'jsdoc2md.json'
- 'typedoc.json'
- 'package.json'
- 'packages/**'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

View File

@@ -5,7 +5,7 @@ on:
branches:
- main
paths:
- "website/**"
- 'website/**'
# - "template/**"
jobs:

2
.gitignore vendored
View File

@@ -3,6 +3,8 @@
# Test file for testing dd changes
debug.ts
testing
# dependencies
node_modules

View File

@@ -7,5 +7,3 @@
tasks:
- init: yarn install && yarn run build && yarn run lint && yarn run build:doc
command: yarn run dev

4
.helix/languages.toml Normal file
View File

@@ -0,0 +1,4 @@
[[language]]
name = "typescript"
formatter = { command = "npx" , args = ["prettier", "--write", "."] }

View File

@@ -2,8 +2,8 @@ nodeLinker: node-modules
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: "@yarnpkg/plugin-typescript"
spec: '@yarnpkg/plugin-typescript'
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
spec: '@yarnpkg/plugin-interactive-tools'
yarnPath: .yarn/releases/yarn-3.3.0.cjs

View File

@@ -11,15 +11,7 @@
"https://deno.land": true
},
"discord.enabled": true,
"cSpell.words": [
"denoland",
"Discordeno",
"Kwik",
"Loglevels",
"msgpack",
"Slowmode",
"upsert"
],
"cSpell.words": ["denoland", "Discordeno", "Kwik", "Loglevels", "msgpack", "Slowmode", "upsert"],
"deno.unstable": true,
"deno.inlayHints.enumMemberValues.enabled": true,
"deno.inlayHints.functionLikeReturnTypes.enabled": true,

View File

@@ -1,7 +1,7 @@
version: '3.8'
services:
influxdb:
image: "influxdb:2.4.0-alpine"
image: 'influxdb:2.4.0-alpine'
ports:
- 127.0.0.1:8086:8086
env_file:

View File

@@ -79,6 +79,6 @@ export async function missingTranslation(language: keyof typeof languages, key:
// type translationKeys = keyof typeof english | string
export type translationKeys = keyof typeof english;
type getArgs<K extends translationKeys> = typeof english[K] extends (...any: any[]) => unknown
? Parameters<typeof english[K]>
type getArgs<K extends translationKeys> = (typeof english)[K] extends (...any: any[]) => unknown
? Parameters<(typeof english)[K]>
: [];

View File

@@ -150,7 +150,7 @@ export type ArgumentDefinition =
| SubcommandArgumentDefinition
| SubcommandGroupArgumentDefinition;
type getName<K extends translationKeys> = typeof english[K] extends string ? typeof english[K] : never;
type getName<K extends translationKeys> = (typeof english)[K] extends string ? (typeof english)[K] : never;
// OPTIONALS MUST BE FIRST!!!
export type ConvertArgumentDefinitionsToArgs<T extends readonly ArgumentDefinition[]> = Identity<

View File

@@ -1,91 +1,91 @@
const resolveFolder = (folderName) => path.resolve(__dirname, ".", folderName);
const fs = require("fs");
const path = require("path");
const resolveFolder = (folderName) => path.resolve(__dirname, '.', folderName)
const fs = require('fs')
const path = require('path')
class CommandManager {
constructor(client) {
this.client = client;
this.cache = new Map();
this.aliases = new Map();
this.client = client
this.cache = new Map()
this.aliases = new Map()
}
load(options = {}) {
const commandFolderPath = options.path || "../Plugins";
const commandFolder = resolveFolder(commandFolderPath);
if (options.category === undefined) options.category = true;
if (options.plugins === undefined) options.plugins = true;
const commandFolderPath = options.path || '../Plugins'
const commandFolder = resolveFolder(commandFolderPath)
if (options.category === undefined) options.category = true
if (options.plugins === undefined) options.plugins = true
// PluginMode will iterate through all SubFolders
fs.readdirSync(commandFolder).map(async (dir) => {
if (dir.endsWith(".txt")) return;
if (!options.category && dir.endsWith(".js")) {
const commandPath = path.join(commandFolder, dir);
this.loadCommand(commandPath);
if (dir.endsWith('.txt')) return
if (!options.category && dir.endsWith('.js')) {
const commandPath = path.join(commandFolder, dir)
this.loadCommand(commandPath)
} else {
fs.readdirSync(path.join(commandFolder, dir)).map((cmd) => {
if (cmd.endsWith(".js") && !options.plugins) {
const commandPath = path.join(commandFolder, dir, cmd);
this.loadCommand(commandPath);
} else if (commandFolderPath === "../Plugins") {
if (cmd !== "commands") return;
if (cmd.endsWith('.js') && !options.plugins) {
const commandPath = path.join(commandFolder, dir, cmd)
this.loadCommand(commandPath)
} else if (commandFolderPath === '../Plugins') {
if (cmd !== 'commands') return
fs.readdirSync(path.join(commandFolder, dir, cmd)).map((cmdfile) => {
if (!cmdfile.endsWith(".js")) return;
const commandPath = path.join(commandFolder, dir, cmd, cmdfile);
this.loadCommand(commandPath);
});
if (!cmdfile.endsWith('.js')) return
const commandPath = path.join(commandFolder, dir, cmd, cmdfile)
this.loadCommand(commandPath)
})
}
});
})
}
});
})
}
loadCommand(commandPath) {
const pull = require(path.join(commandPath));
const pull = require(path.join(commandPath))
if (pull.name) {
pull.path = commandPath;
this.cache.set(pull.name, pull);
pull.path = commandPath
this.cache.set(pull.name, pull)
}
if (pull.aliases) {
pull.aliases.map((p) => this.aliases.set(p, pull));
pull.aliases.map((p) => this.aliases.set(p, pull))
}
return pull;
return pull
}
reloadCommand(commandName) {
const command = this.cache.get(commandName);
if (!command) return;
const commandPath = path.join(command.path);
delete require.cache[require.resolve(commandPath)];
return this.loadCommand(commandPath);
const command = this.cache.get(commandName)
if (!command) return
const commandPath = path.join(command.path)
delete require.cache[require.resolve(commandPath)]
return this.loadCommand(commandPath)
}
isCommand(message) {
if (message.isFromBot) return false;
const prefix = "!";
const escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
const prefixRegex = new RegExp(`^(<@!?${this.client.id}>|${escapeRegex(prefix)})\\s*`);
if (!prefixRegex.test(message.content)) return false;
if (message.isFromBot) return false
const prefix = '!'
const escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
const prefixRegex = new RegExp(`^(<@!?${this.client.id}>|${escapeRegex(prefix)})\\s*`)
if (!prefixRegex.test(message.content)) return false
const [, matchedPrefix] = message.content.match(prefixRegex);
const args = message.content.slice(matchedPrefix.length).trim().split(/ +/);
const [, matchedPrefix] = message.content.match(prefixRegex)
const args = message.content.slice(matchedPrefix.length).trim().split(/ +/)
this.onMessage(message, prefix, args);
return true;
this.onMessage(message, prefix, args)
return true
}
isInteraction(interaction) {
if (interaction.type !== 2) return;
this.onInteraction(interaction);
if (interaction.type !== 2) return
this.onInteraction(interaction)
}
async onMessage(message, guild, args) {
const commandName = args.shift().toLowerCase();
const command = this.cache.get(commandName); // || this.cache.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
const commandName = args.shift().toLowerCase()
const command = this.cache.get(commandName) // || this.cache.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
if (!command && message.content.includes(this.client.id)) {
// Handle, when Command has not been found
const options = { content: "I did not found the Command!" };
this.client.helpers.sendMessage(message.channelId, options);
const options = { content: 'I did not found the Command!' }
this.client.helpers.sendMessage(message.channelId, options)
}
if (!command) return;
if (!command) return
const messagecommand = new command({
manager: this,
@@ -94,30 +94,30 @@ class CommandManager {
args,
settings: {},
commandName: command.name,
});
})
messagecommand.execute()?.catch?.((error) => {
console.log(error);
console.log(error)
// Call Function on CommandResponse.js, handle the error
return messagecommand.onError(error ?? "custom");
});
return messagecommand.onError(error ?? 'custom')
})
}
async onInteraction(interaction) {
const command = this.cache.get(interaction.data.name);
if (!command) return;
const command = this.cache.get(interaction.data.name)
if (!command) return
const args = [];
const args = []
// Map all Values and Args
interaction.data.options?.map((o) => {
if (o.name) args.push(o.name);
if (o.name) args.push(o.name)
if (o.options) {
o.options.map((o2) => {
if (o2.value) return args.push(o2.value);
if (o2.name) args.push(o2.name);
if (o2.options) o2.options.map((v) => args.push(v.value));
});
if (o2.value) return args.push(o2.value)
if (o2.name) args.push(o2.name)
if (o2.options) o2.options.map((v) => args.push(v.value))
})
}
});
})
const messagecommand = new command({
manager: this,
@@ -126,12 +126,12 @@ class CommandManager {
args,
settings: {},
commandName: command.name,
});
})
messagecommand.execute()?.catch?.((error) => {
console.log(error);
console.log(error)
// Call Function on CommandResponse.js, handle the error
return messagecommand.onError(error ?? "custom");
});
return messagecommand.onError(error ?? 'custom')
})
}
}
module.exports = CommandManager;
module.exports = CommandManager

View File

@@ -1,32 +1,32 @@
const fs = require("fs");
const path = require("path");
const resolveFolder = (folderName) => path.resolve(__dirname, ".", folderName);
const fs = require('fs')
const path = require('path')
const resolveFolder = (folderName) => path.resolve(__dirname, '.', folderName)
const EventEmitter = require("events");
const EventEmitter = require('events')
class EventManager extends EventEmitter {
constructor() {
super();
this.cache = new Map();
this.allEvents = {};
super()
this.cache = new Map()
this.allEvents = {}
}
load(options = {}) {
const eventsFolder = resolveFolder("../events");
let i = 0;
const eventsFolder = resolveFolder('../events')
let i = 0
fs.readdirSync(eventsFolder).map(async (file) => {
if (!file.endsWith(".js")) return;
i++;
const fileName = path.join(eventsFolder, file);
const event = require(fileName);
const eventName = file.split(".")[0];
if (!file.endsWith('.js')) return
i++
const fileName = path.join(eventsFolder, file)
const event = require(fileName)
const eventName = file.split('.')[0]
this.allEvents[`${eventName}`] = (...args) => {
this.emit(eventName, ...args);
return event(...args);
};
});
return this.allEvents;
this.emit(eventName, ...args)
return event(...args)
}
})
return this.allEvents
}
}
module.exports = EventManager;
module.exports = EventManager

View File

@@ -1,51 +1,56 @@
const Discord = require("discordeno.js");
const Discord = require('discordeno.js')
const BaseCommand = require("../../../Structures/BaseCommand.js");
const BaseCommand = require('../../../Structures/BaseCommand.js')
class evalcommand extends BaseCommand {
static name = "eval";
static description = "danger !!!";
static category = "Developer";
static slash = { name: "eval", category: "dev" };
static name = 'eval'
static description = 'danger !!!'
static category = 'Developer'
static slash = { name: 'eval', category: 'dev' }
constructor(data) {
super(data);
super(data)
}
async execute() {
if (!this.client.config.owners.includes(String(this.user.id))) return;
if (!(this.args.length > 0)) return this.reply({ content: "**You must provide something to eval!**" });
if (!this.client.config.owners.includes(String(this.user.id))) return
if (!(this.args.length > 0)) return this.reply({ content: '**You must provide something to eval!**' })
const inputOfEval = this.args.join(" ");
let outputOfEval;
let typeOfEval;
const inputOfEval = this.args.join(' ')
let outputOfEval
let typeOfEval
try {
if (this.args.includes("await")) {
outputOfEval = await eval("(async () => {" + inputOfEval + "})()");
if (this.args.includes('await')) {
outputOfEval = await eval('(async () => {' + inputOfEval + '})()')
} else {
outputOfEval = await eval(inputOfEval);
outputOfEval = await eval(inputOfEval)
}
} catch (e) {
outputOfEval = e.message;
typeOfEval = e.name;
outputOfEval = e.message
typeOfEval = e.name
}
const seen = [];
outputOfEval = typeof outputOfEval === "object"
? JSON.stringify(outputOfEval, (_, value) => {
if (value == `Bot ${this.client.config.token}`) return `BOT_TOKEN`;
if (typeof value === "bigint") value = value.toString();
if (typeof value === "object" && value !== null) {
if (seen.indexOf(value) !== -1) return;
else seen.push(value);
const seen = []
outputOfEval =
typeof outputOfEval === 'object'
? JSON.stringify(
outputOfEval,
(_, value) => {
if (value == `Bot ${this.client.config.token}`) return `BOT_TOKEN`
if (typeof value === 'bigint') value = value.toString()
if (typeof value === 'object' && value !== null) {
if (seen.indexOf(value) !== -1) return
else seen.push(value)
}
return value;
}, 1)
: outputOfEval;
return value
},
1,
)
: outputOfEval
const embed = new Discord.Embed()
.addField({ name: "Input", value: "```js\n" + inputOfEval + "```" })
.addField({ name: "Output", value: "```json\n" + `${outputOfEval}`.slice(0, 1000) + "```" });
this.reply({ embeds: [embed] });
.addField({ name: 'Input', value: '```js\n' + inputOfEval + '```' })
.addField({ name: 'Output', value: '```json\n' + `${outputOfEval}`.slice(0, 1000) + '```' })
this.reply({ embeds: [embed] })
}
}
module.exports = evalcommand;
module.exports = evalcommand

View File

@@ -1,19 +1,19 @@
const BaseCommand = require("../../../Structures/BaseCommand.js");
const BaseCommand = require('../../../Structures/BaseCommand.js')
class reloadcommand extends BaseCommand {
static name = "reload";
static description = "Reloads a Command";
static category = "Developer";
static slash = { name: "reload", category: "dev" };
static name = 'reload'
static description = 'Reloads a Command'
static category = 'Developer'
static slash = { name: 'reload', category: 'dev' }
constructor(data) {
super(data);
super(data)
}
async execute() {
if (!this.client.config.owners.includes(String(this.user.id))) return;
if (!this.args[0]) return this.reply({ content: "**You must provide a command to reload!**" });
const op = this.client.commands.reloadCommand(this.args[0]);
if (!op) return this.reply({ content: "**That command doesn't exist!**" });
return this.reply({ content: "**Reloaded Command: `" + this.args[0] + "`**" });
if (!this.client.config.owners.includes(String(this.user.id))) return
if (!this.args[0]) return this.reply({ content: '**You must provide a command to reload!**' })
const op = this.client.commands.reloadCommand(this.args[0])
if (!op) return this.reply({ content: "**That command doesn't exist!**" })
return this.reply({ content: '**Reloaded Command: `' + this.args[0] + '`**' })
}
}
module.exports = reloadcommand;
module.exports = reloadcommand

View File

@@ -1,25 +1,23 @@
const BaseCommand = require("../../../Structures/BaseCommand.js");
const Discord = require("discordeno.js");
const BaseCommand = require('../../../Structures/BaseCommand.js')
const Discord = require('discordeno.js')
class pingcommand extends BaseCommand {
static name = "ping";
static description = "See if the bot latency is okay";
static usage = "";
static category = "General";
static slash = { name: "ping", category: "info" };
static name = 'ping'
static description = 'See if the bot latency is okay'
static usage = ''
static category = 'General'
static slash = { name: 'ping', category: 'info' }
constructor(data) {
super(data);
super(data)
}
async execute() {
const msg = await this.channel.send({ content: `Pinging...` });
const msg = await this.channel.send({ content: `Pinging...` })
// Assign properties to the response
const ping = msg.timestamp - (this.message ? this.message.timestamp : this.interaction.timestamp);
const ping = msg.timestamp - (this.message ? this.message.timestamp : this.interaction.timestamp)
const embed = new Discord.Embed()
.setTitle(`The Bots ping is ${ping} ms`)
.toJSON();
const embed = new Discord.Embed().setTitle(`The Bots ping is ${ping} ms`).toJSON()
// Edit Message with the Embed
return this.reply({ embeds: [embed] });
return this.reply({ embeds: [embed] })
}
}
module.exports = pingcommand;
module.exports = pingcommand

View File

@@ -1,41 +1,47 @@
const BaseCommand = require("../../../Structures/BaseCommand.js");
const Discord = require("discordeno.js");
const BaseCommand = require('../../../Structures/BaseCommand.js')
const Discord = require('discordeno.js')
class bancommand extends BaseCommand {
static name = "ban";
static description = "Ban a user from the server";
static usage = "";
static category = "Moderation";
static slash = { name: "ban", category: "mod" };
static name = 'ban'
static description = 'Ban a user from the server'
static usage = ''
static category = 'Moderation'
static slash = { name: 'ban', category: 'mod' }
constructor(data) {
super(data);
super(data)
}
async execute() {
// Show Case Modal
// Because no permission system has not been added
if (!this.client.config.owners.includes(String(this.user.id))) return;
if (!this.client.config.owners.includes(String(this.user.id))) return
const textinput = new Discord.Component()
.setType("TEXT_INPUT")
.setStyle("SHORT")
.setCustomId("t1")
.setLabel("User ID")
.setPlaceholder("User ID")
.setType('TEXT_INPUT')
.setStyle('SHORT')
.setCustomId('t1')
.setLabel('User ID')
.setPlaceholder('User ID')
.setRequired(true)
.setMaxLength(20)
.setMinLength(1)
.setValue(this.args[0])
.toJSON();
const textinput2 = new Discord.Component().setType("TEXT_INPUT").setStyle("PARAGRAPH").setCustomId("t2")
.setLabel("Reason").setPlaceholder("Reason for Ban").setRequired(false)
.setMaxLength(300).toJSON();
.toJSON()
const textinput2 = new Discord.Component()
.setType('TEXT_INPUT')
.setStyle('PARAGRAPH')
.setCustomId('t2')
.setLabel('Reason')
.setPlaceholder('Reason for Ban')
.setRequired(false)
.setMaxLength(300)
.toJSON()
const actionrow = new Discord.Component().setType(1).setComponents(textinput).toJSON();
const actionrow2 = new Discord.Component().setType(1).setComponents(textinput2).toJSON();
const actionrow = new Discord.Component().setType(1).setComponents(textinput).toJSON()
const actionrow2 = new Discord.Component().setType(1).setComponents(textinput2).toJSON()
this.interaction.popupModal({ customId: "ban_modal", title: "Ban User", components: [actionrow, actionrow2] });
this.interaction.popupModal({ customId: 'ban_modal', title: 'Ban User', components: [actionrow, actionrow2] })
}
}
module.exports = bancommand;
module.exports = bancommand

View File

@@ -1,82 +1,89 @@
const BaseCommand = require("../../../Structures/BaseCommand.js");
const BaseCommand = require('../../../Structures/BaseCommand.js')
const { Interaction, Collector, ComponentOptions, Embed, Component } = require("discordeno.js");
const { Interaction, Collector, ComponentOptions, Embed, Component } = require('discordeno.js')
class warncommand extends BaseCommand {
static name = "warn";
static description = "Warn a user from the server";
static usage = "";
static category = "Moderation";
static slash = { name: "warn", category: "mod" };
static name = 'warn'
static description = 'Warn a user from the server'
static usage = ''
static category = 'Moderation'
static slash = { name: 'warn', category: 'mod' }
constructor(data) {
super(data);
super(data)
}
async execute() {
// Show Case Modal
if (!this.interaction) return this.reply("You currently can just use this command as slash command.");
if (!this.interaction) return this.reply('You currently can just use this command as slash command.')
if (!this.interaction.member.permissions.has("KICK_MEMBERS")) {
return this.reply("You need the permission `KICK_MEMBERS` to use this command.");
if (!this.interaction.member.permissions.has('KICK_MEMBERS')) {
return this.reply('You need the permission `KICK_MEMBERS` to use this command.')
}
const textinput = new Component()
.setType("TEXT_INPUT")
.setStyle("SHORT")
.setCustomId("t1")
.setLabel("User ID")
.setPlaceholder("User ID")
.setType('TEXT_INPUT')
.setStyle('SHORT')
.setCustomId('t1')
.setLabel('User ID')
.setPlaceholder('User ID')
.setRequired(true)
.setMaxLength(20)
.setMinLength(1)
.setValue(this.args[0])
.toJSON();
const textinput2 = new Component().setType("TEXT_INPUT").setStyle("PARAGRAPH").setCustomId("t2")
.setLabel("Reason").setPlaceholder("Reason for Warning").setRequired(false)
.setMaxLength(300).toJSON();
.toJSON()
const textinput2 = new Component()
.setType('TEXT_INPUT')
.setStyle('PARAGRAPH')
.setCustomId('t2')
.setLabel('Reason')
.setPlaceholder('Reason for Warning')
.setRequired(false)
.setMaxLength(300)
.toJSON()
const actionrow = new Component().setType(1).setComponents(textinput).toJSON();
const actionrow2 = new Component().setType(1).setComponents(textinput2).toJSON();
const actionrow = new Component().setType(1).setComponents(textinput).toJSON()
const actionrow2 = new Component().setType(1).setComponents(textinput2).toJSON()
this.interaction.popupModal({ customId: "warn_modal", title: "Warn User", components: [actionrow, actionrow2] });
this.interaction.popupModal({ customId: 'warn_modal', title: 'Warn User', components: [actionrow, actionrow2] })
const filter = (m) => m.data?.customId === "warn_modal";
const collector = new Collector("interactionCreate", { client: this.client, timeout: 60000, filter });
collector.on("collect", (m) => {
const options = new ComponentOptions(m.data.components);
const i = new Interaction(this.client, m);
collector.stop();
const filter = (m) => m.data?.customId === 'warn_modal'
const collector = new Collector('interactionCreate', { client: this.client, timeout: 60000, filter })
collector.on('collect', (m) => {
const options = new ComponentOptions(m.data.components)
const i = new Interaction(this.client, m)
collector.stop()
const memberId = options.get("t1").value;
const reason = options.get("t2").value;
const memberId = options.get('t1').value
const reason = options.get('t2').value
const embed = new Embed()
.setTitle("Warned User:")
.setDescription(`User ID: <@${memberId}> \n Reason: ${reason}`)
.setColor(0x00ff00)
.toJSON();
const embed = new Embed().setTitle('Warned User:').setDescription(`User ID: <@${memberId}> \n Reason: ${reason}`).setColor(0x00ff00).toJSON()
const warnMessage = new Embed()
.setTitle("Warning:")
.setDescription(`You have been warned in **${this.guild.name}** for ${"`" + reason + "`"}`)
.toJSON();
.setTitle('Warning:')
.setDescription(`You have been warned in **${this.guild.name}** for ${'`' + reason + '`'}`)
.toJSON()
this.guild.members.fetch(memberId).then((m) => {
m.send({ embeds: [warnMessage] }).then(() => {
i.reply({ embeds: [embed] });
}).catch((e) => {
console.log(e);
i.reply({ content: `Could not warn user ${"<@" + m.id + ">"} | They likely do not have their DMs open.` });
});
}).catch((e) => {
this.guild.members
.fetch(memberId)
.then((m) => {
m.send({ embeds: [warnMessage] })
.then(() => {
i.reply({ embeds: [embed] })
})
.catch((e) => {
console.log(e)
i.reply({ content: `Could not warn user ${'<@' + m.id + '>'} | They likely do not have their DMs open.` })
})
})
.catch((e) => {
const embed = new Embed()
.setTitle("Member not found")
.setDescription(`The member with the ID of ${"`" + memberId + "`"} has not been found in this Server.`)
.setTitle('Member not found')
.setDescription(`The member with the ID of ${'`' + memberId + '`'} has not been found in this Server.`)
.setColor(0xff0000)
.toJSON();
i.reply({ embeds: [embed] });
});
});
.toJSON()
i.reply({ embeds: [embed] })
})
})
}
}
module.exports = warncommand;
module.exports = warncommand

View File

@@ -1,15 +1,15 @@
const UtilCommand = require("./CommandResponse.js");
const UtilCommand = require('./CommandResponse.js')
class BaseCommand extends UtilCommand {
constructor(data) {
super(data);
this.message = data.message;
this.interaction = data.interaction;
this.user = this.message ? this.message.author : this.interaction.user;
this.guild = this.message ? this.message.guild : this.interaction.guild;
this.member = this.message ? this.message.member : this.interaction.member;
this.channel = this.message ? this.message.channel : this.interaction.channel;
this.client = data.client;
this.settings = data.settings ?? {};
super(data)
this.message = data.message
this.interaction = data.interaction
this.user = this.message ? this.message.author : this.interaction.user
this.guild = this.message ? this.message.guild : this.interaction.guild
this.member = this.message ? this.message.member : this.interaction.member
this.channel = this.message ? this.message.channel : this.interaction.channel
this.client = data.client
this.settings = data.settings ?? {}
}
}
module.exports = BaseCommand;
module.exports = BaseCommand

View File

@@ -1,50 +1,50 @@
class Responses {
constructor(data) {
this.manager = data.manager;
this.args = this._validateArguments(data.args);
this.replied = false;
this.manager = data.manager
this.args = this._validateArguments(data.args)
this.replied = false
}
async reply(content) {
// When just a string is passed, we assume it's the content -> transform to correct formatted payload
if (typeof content === "string") content = { content };
if (typeof content === 'string') content = { content }
if (this.interaction) {
if (this.replied) return this.followUp(content);
const reply = await this.interaction.reply(content);
this.replied = true;
return {};
if (this.replied) return this.followUp(content)
const reply = await this.interaction.reply(content)
this.replied = true
return {}
}
if (this.message) {
if (this.replied) return this.followUp(content);
if (this.replied) return this.followUp(content)
const msg = await this.message.channel.send(content);
const msg = await this.message.channel.send(content)
// Assign properties to the response
const response = this.client.messages.forge(msg);
this.replied = true;
return response;
const response = this.client.messages.forge(msg)
this.replied = true
return response
}
}
async followUp(content) {
if (this.interaction) {
const reply = await this.interaction.followUp(content);
return {};
const reply = await this.interaction.followUp(content)
return {}
}
if (this.message) {
const msg = await this.message.channel.send(content);
const response = this.client.messages.forge(msg);
return response;
const msg = await this.message.channel.send(content)
const response = this.client.messages.forge(msg)
return response
}
}
onError(error) {
return this.reply({ content: `A unknown Error happend: \n> ${error}` });
return this.reply({ content: `A unknown Error happend: \n> ${error}` })
}
_validateArguments(args) {
this.args = args;
return args;
this.args = args
return args
}
}
module.exports = Responses;
module.exports = Responses

View File

@@ -1,4 +1,4 @@
module.exports = async (client, interaction) => {
interaction = client.interactions.forge(interaction);
client.commands.isInteraction(interaction);
};
interaction = client.interactions.forge(interaction)
client.commands.isInteraction(interaction)
}

View File

@@ -1,4 +1,4 @@
module.exports = async (client, message) => {
message = client.messages.forge(message);
client.commands.isCommand(message);
};
message = client.messages.forge(message)
client.commands.isCommand(message)
}

View File

@@ -1,7 +1,7 @@
module.exports = async (client, payload) => {
client.user = client.users.forge(payload.user);
client.user = client.users.forge(payload.user)
if (payload.shardId === client.gateway.lastShardId) {
// All Shards are ready
console.log("Successfully connected to the gateway as " + client.user.tag);
console.log('Successfully connected to the gateway as ' + client.user.tag)
}
}
};

View File

@@ -1,30 +1,30 @@
require("dotenv").config();
require('dotenv').config()
const Discord = require("discordeno.js");
const Discord = require('discordeno.js')
// Ideally you should switch this to .env but for a template a config json is enough
const config = require("./config.json");
const config = require('./config.json')
const EventManager = require("./Managers/EventManager.js");
const EventManager = require('./Managers/EventManager.js')
// looping through all events and registering them
const events = new EventManager({});
const events = new EventManager({})
const baseBot = Discord.createBot({
events: events.load({}),
intents: Discord.Intents.Guilds | Discord.Intents.GuildMessages | Discord.Intents.MessageContent,
token: process.env.TOKEN,
});
const client = Discord.enableCachePlugin(baseBot, {});
})
const client = Discord.enableCachePlugin(baseBot, {})
client.config = config;
client.config = config
// looping through all commands and registering them in .cache of the class
const CommandManager = require("./Managers/CommandManager.js");
client.commands = new CommandManager(client);
client.commands.load({});
const CommandManager = require('./Managers/CommandManager.js')
client.commands = new CommandManager(client)
client.commands.load({})
// Starts your Bot
Discord.startBot(client);
Discord.startBot(client)
/*
* You should handle all errors and fix the issues in your codes...

View File

@@ -3,10 +3,7 @@
"babelrc": false,
"extensions": ["ts", "tsx"],
"ignore": ["**/*.(test|spec).ts"],
"plugins": [
"@babel/proposal-class-properties",
"@babel/proposal-object-rest-spread"
],
"plugins": ["@babel/proposal-class-properties", "@babel/proposal-object-rest-spread"],
"presets": [
[
"@babel/preset-env",

View File

@@ -1,16 +1,8 @@
{
"extends": "tsconfig/base.json",
"compilerOptions": {
"outDir": "./dist",
"outDir": "./dist"
},
"include": [
"./src/**/*.ts",
"./src/**/*.tsx"
],
"exclude": [
"node_modules",
"dist",
"test",
"tests"
]
"include": ["./src/**/*.ts", "./src/**/*.tsx"],
"exclude": ["node_modules", "dist", "test", "tests"]
}

View File

@@ -1,12 +1,12 @@
export * from "./CHANNEL_CREATE.js";
export * from "./CHANNEL_DELETE.js";
export * from "./CHANNEL_PINS_UPDATE.js";
export * from "./CHANNEL_UPDATE.js";
export * from "./STAGE_INSTANCE_CREATE.js";
export * from "./STAGE_INSTANCE_DELETE.js";
export * from "./STAGE_INSTANCE_UPDATE.js";
export * from "./THREAD_CREATE.js";
export * from "./THREAD_DELETE.js";
export * from "./THREAD_LIST_SYNC.js";
export * from "./THREAD_MEMBERS_UPDATE.js";
export * from "./THREAD_UPDATE.js";
export * from './CHANNEL_CREATE.js'
export * from './CHANNEL_DELETE.js'
export * from './CHANNEL_PINS_UPDATE.js'
export * from './CHANNEL_UPDATE.js'
export * from './STAGE_INSTANCE_CREATE.js'
export * from './STAGE_INSTANCE_DELETE.js'
export * from './STAGE_INSTANCE_UPDATE.js'
export * from './THREAD_CREATE.js'
export * from './THREAD_DELETE.js'
export * from './THREAD_LIST_SYNC.js'
export * from './THREAD_MEMBERS_UPDATE.js'
export * from './THREAD_UPDATE.js'

View File

@@ -1 +1 @@
export * from "./GUILD_EMOJIS_UPDATE.js";
export * from './GUILD_EMOJIS_UPDATE.js'

View File

@@ -7,6 +7,6 @@ export async function handleGuildStickersUpdate(bot: Bot, data: DiscordGatewayPa
payload.stickers.map((sticker) => {
sticker.guild_id = payload.guild_id
return bot.transformers.sticker(bot, sticker)
})
}),
)
}

View File

@@ -1,11 +1,11 @@
export * from "./automod/index.js";
export * from "./scheduledEvents/index.js";
export * from './automod/index.js'
export * from './scheduledEvents/index.js'
export * from "./GUILD_AUDIT_LOG_ENTRY_CREATE.js";
export * from "./GUILD_BAN_ADD.js";
export * from "./GUILD_BAN_REMOVE.js";
export * from "./GUILD_CREATE.js";
export * from "./GUILD_DELETE.js";
export * from "./GUILD_INTEGRATIONS_UPDATE.js";
export * from "./GUILD_STICKERS_UPDATE.js";
export * from "./GUILD_UPDATE.js";
export * from './GUILD_AUDIT_LOG_ENTRY_CREATE.js'
export * from './GUILD_BAN_ADD.js'
export * from './GUILD_BAN_REMOVE.js'
export * from './GUILD_CREATE.js'
export * from './GUILD_DELETE.js'
export * from './GUILD_INTEGRATIONS_UPDATE.js'
export * from './GUILD_STICKERS_UPDATE.js'
export * from './GUILD_UPDATE.js'

View File

@@ -1,5 +1,5 @@
export * from "./GUILD_SCHEDULED_EVENT_CREATE.js";
export * from "./GUILD_SCHEDULED_EVENT_DELETE.js";
export * from "./GUILD_SCHEDULED_EVENT_UPDATE.js";
export * from "./GUILD_SCHEDULED_EVENT_USER_ADD.js";
export * from "./GUILD_SCHEDULED_EVENT_USER_REMOVE.js";
export * from './GUILD_SCHEDULED_EVENT_CREATE.js'
export * from './GUILD_SCHEDULED_EVENT_DELETE.js'
export * from './GUILD_SCHEDULED_EVENT_UPDATE.js'
export * from './GUILD_SCHEDULED_EVENT_USER_ADD.js'
export * from './GUILD_SCHEDULED_EVENT_USER_REMOVE.js'

View File

@@ -1,3 +1,3 @@
export * from "./INTEGRATION_CREATE.js";
export * from "./INTEGRATION_DELETE.js";
export * from "./INTEGRATION_UPDATE.js";
export * from './INTEGRATION_CREATE.js'
export * from './INTEGRATION_DELETE.js'
export * from './INTEGRATION_UPDATE.js'

View File

@@ -1,4 +1,4 @@
import type { Bot, DiscordGatewayPayload, DiscordGuildApplicationCommandPermissions } from "../..";
import type { Bot, DiscordGatewayPayload, DiscordGuildApplicationCommandPermissions } from '../..'
export async function handleApplicationCommandPermissionsUpdate(bot: Bot, data: DiscordGatewayPayload, shardId: number): Promise<void> {
const payload = data.d as DiscordGuildApplicationCommandPermissions

View File

@@ -1,2 +1,2 @@
export * from "./INVITE_CREATE.js";
export * from "./INVITE_DELETE.js";
export * from './INVITE_CREATE.js'
export * from './INVITE_DELETE.js'

View File

@@ -1,4 +1,4 @@
export * from "./GUILD_MEMBER_ADD.js";
export * from "./GUILD_MEMBER_REMOVE.js";
export * from "./GUILD_MEMBER_UPDATE.js";
export * from "./GUILD_MEMBERS_CHUNK.js";
export * from './GUILD_MEMBER_ADD.js'
export * from './GUILD_MEMBER_REMOVE.js'
export * from './GUILD_MEMBER_UPDATE.js'
export * from './GUILD_MEMBERS_CHUNK.js'

View File

@@ -1,8 +1,8 @@
export * from "./MESSAGE_CREATE.js";
export * from "./MESSAGE_DELETE_BULK.js";
export * from "./MESSAGE_DELETE.js";
export * from "./MESSAGE_REACTION_ADD.js";
export * from "./MESSAGE_REACTION_REMOVE_ALL.js";
export * from "./MESSAGE_REACTION_REMOVE_EMOJI.js";
export * from "./MESSAGE_REACTION_REMOVE.js";
export * from "./MESSAGE_UPDATE.js";
export * from './MESSAGE_CREATE.js'
export * from './MESSAGE_DELETE_BULK.js'
export * from './MESSAGE_DELETE.js'
export * from './MESSAGE_REACTION_ADD.js'
export * from './MESSAGE_REACTION_REMOVE_ALL.js'
export * from './MESSAGE_REACTION_REMOVE_EMOJI.js'
export * from './MESSAGE_REACTION_REMOVE.js'
export * from './MESSAGE_UPDATE.js'

View File

@@ -1,4 +1,4 @@
export * from "./PRESENCE_UPDATE.js";
export * from "./READY.js";
export * from "./TYPING_START.js";
export * from "./USER_UPDATE.js";
export * from './PRESENCE_UPDATE.js'
export * from './READY.js'
export * from './TYPING_START.js'
export * from './USER_UPDATE.js'

View File

@@ -1,3 +1,3 @@
export * from "./GUILD_ROLE_CREATE.js";
export * from "./GUILD_ROLE_DELETE.js";
export * from "./GUILD_ROLE_UPDATE.js";
export * from './GUILD_ROLE_CREATE.js'
export * from './GUILD_ROLE_DELETE.js'
export * from './GUILD_ROLE_UPDATE.js'

View File

@@ -1,2 +1,2 @@
export * from "./VOICE_SERVER_UPDATE.js";
export * from "./VOICE_STATE_UPDATE.js";
export * from './VOICE_SERVER_UPDATE.js'
export * from './VOICE_STATE_UPDATE.js'

View File

@@ -1 +1 @@
export * from "./WEBHOOKS_UPDATE.js";
export * from './WEBHOOKS_UPDATE.js'

View File

@@ -1,16 +1,16 @@
export * from "./activity.js";
export * from "./application.js";
export * from "./applicationCommand.js";
export * from "./applicationCommandOption.js";
export * from "./applicationCommandOptionChoice.js";
export * from "./applicationCommandPermission.js";
export * from "./attachment.js";
export * from "./auditLogEntry.js";
export * from "./component.js";
export * from "./embed.js";
export * from "./emoji.js";
export * from "./gatewayBot.js";
export * from "./member.js";
export * from "./presence.js";
export * from "./team.js";
export * from "./widgetSettings.js";
export * from './activity.js'
export * from './application.js'
export * from './applicationCommand.js'
export * from './applicationCommandOption.js'
export * from './applicationCommandOptionChoice.js'
export * from './applicationCommandPermission.js'
export * from './attachment.js'
export * from './auditLogEntry.js'
export * from './component.js'
export * from './embed.js'
export * from './emoji.js'
export * from './gatewayBot.js'
export * from './member.js'
export * from './presence.js'
export * from './team.js'
export * from './widgetSettings.js'

View File

@@ -1,49 +1,49 @@
export class ToggleBitfield {
bitfield = 0;
bitfield = 0
constructor(bitfield?: number) {
if (bitfield) this.bitfield = bitfield;
if (bitfield) this.bitfield = bitfield
}
/** Tests whether or not this bitfield has the permission requested. */
contains(bits: number): boolean {
return Boolean(this.bitfield & bits);
return Boolean(this.bitfield & bits)
}
/** Adds some bits to the bitfield. */
add(bits: number): this {
this.bitfield |= bits;
return this;
this.bitfield |= bits
return this
}
/** Removes some bits from the bitfield. */
remove(bits: number): this {
this.bitfield &= ~bits;
return this;
this.bitfield &= ~bits
return this
}
}
export class ToggleBitfieldBigint {
bitfield = 0n;
bitfield = 0n
constructor(bitfield?: bigint) {
if (bitfield) this.bitfield = bitfield;
if (bitfield) this.bitfield = bitfield
}
/** Tests whether or not this bitfield has the permission requested. */
contains(bits: bigint): boolean {
return Boolean(this.bitfield & bits);
return Boolean(this.bitfield & bits)
}
/** Adds some bits to the bitfield. */
add(bits: bigint): this {
this.bitfield |= bits;
return this;
this.bitfield |= bits
return this
}
/** Removes some bits from the bitfield. */
remove(bits: bigint): this {
this.bitfield &= ~bits;
return this;
this.bitfield &= ~bits
return this
}
}

View File

@@ -1,7 +1,7 @@
export * from "./emoji.js";
export * from "./guild.js";
export * from "./member.js";
export * from "./role.js";
export * from "./ToggleBitfield.js";
export * from "./user.js";
export * from "./voice.js";
export * from './emoji.js'
export * from './guild.js'
export * from './member.js'
export * from './role.js'
export * from './ToggleBitfield.js'
export * from './user.js'
export * from './voice.js'

View File

@@ -1,16 +1,8 @@
{
"extends": "tsconfig/base.json",
"compilerOptions": {
"outDir": "./dist",
"outDir": "./dist"
},
"include": [
"./src/**/*.ts",
"./src/**/*.tsx"
],
"exclude": [
"node_modules",
"dist",
"test",
"tests"
]
"include": ["./src/**/*.ts", "./src/**/*.tsx"],
"exclude": ["node_modules", "dist", "test", "tests"]
}

View File

@@ -1,11 +1,5 @@
{
"extends": "tsconfig/test.json",
"include": [
"tests",
],
"exclude": [
"node_modules",
"dist",
"src"
]
"include": ["tests"],
"exclude": ["node_modules", "dist", "src"]
}

View File

@@ -1,16 +1,8 @@
{
"extends": "tsconfig/base.json",
"compilerOptions": {
"outDir": "./dist",
"outDir": "./dist"
},
"include": [
"./src/**/*.ts",
"./src/**/*.tsx"
],
"exclude": [
"node_modules",
"dist",
"test",
"tests"
]
"include": ["./src/**/*.ts", "./src/**/*.tsx"],
"exclude": ["node_modules", "dist", "test", "tests"]
}

View File

@@ -1,11 +1,5 @@
{
"extends": "tsconfig/test.json",
"include": [
"tests",
],
"exclude": [
"node_modules",
"dist",
"src"
]
"include": ["tests"],
"exclude": ["node_modules", "dist", "src"]
}

View File

@@ -467,7 +467,7 @@ export class DiscordenoShard {
this.previousSequenceNumber = packet.s
}
this.forwardToBot(packet);
this.forwardToBot(packet)
}
forwardToBot(packet: DiscordGatewayPayload): void {

View File

@@ -1,16 +1,8 @@
{
"extends": "tsconfig/base.json",
"compilerOptions": {
"outDir": "./dist",
"outDir": "./dist"
},
"include": [
"./src/**/*.ts",
"./src/**/*.tsx"
],
"exclude": [
"node_modules",
"dist",
"test",
"tests"
]
"include": ["./src/**/*.ts", "./src/**/*.tsx"],
"exclude": ["node_modules", "dist", "test", "tests"]
}

View File

@@ -1,11 +1,5 @@
{
"extends": "tsconfig/test.json",
"include": [
"tests",
],
"exclude": [
"node_modules",
"dist",
"src"
]
"include": ["tests"],
"exclude": ["node_modules", "dist", "src"]
}

View File

@@ -119,6 +119,5 @@ describe('Manage Guilds', async () => {
// description: 'some description',
// })
// })
})

View File

@@ -11,8 +11,8 @@ export const rest = createRestManager({
})
rest.deleteQueueDelay = 10000
const guild = await rest.createGuild({ name: 'ddenotester' });
const channel = await rest.createChannel(guild.id, { name: "ddenotestchannel" });
const guild = await rest.createGuild({ name: 'ddenotester' })
const channel = await rest.createChannel(guild.id, { name: 'ddenotestchannel' })
export const e2ecache = {
guild,

View File

@@ -107,5 +107,3 @@ describe('Webhook helpers', async () => {
await expect(rest.getWebhookMessage(webhook.id, webhook.token!, message!.id)).to.eventually.rejected
})
})

View File

@@ -1,16 +1,8 @@
{
"extends": "tsconfig/base.json",
"compilerOptions": {
"outDir": "./dist",
"outDir": "./dist"
},
"include": [
"./src/**/*.ts",
"./src/**/*.tsx"
],
"exclude": [
"node_modules",
"dist",
"test",
"tests"
]
"include": ["./src/**/*.ts", "./src/**/*.tsx"],
"exclude": ["node_modules", "dist", "test", "tests"]
}

View File

@@ -1,11 +1,5 @@
{
"extends": "tsconfig/test.json",
"include": [
"tests",
],
"exclude": [
"node_modules",
"dist",
"src"
]
"include": ["tests"],
"exclude": ["node_modules", "dist", "src"]
}

View File

@@ -1,16 +1,8 @@
{
"extends": "tsconfig/base.json",
"compilerOptions": {
"outDir": "./dist",
"outDir": "./dist"
},
"include": [
"./src/**/*.ts",
"./src/**/*.tsx"
],
"exclude": [
"node_modules",
"dist",
"test",
"tests"
]
"include": ["./src/**/*.ts", "./src/**/*.tsx"],
"exclude": ["node_modules", "dist", "test", "tests"]
}

View File

@@ -1,11 +1,5 @@
{
"extends": "tsconfig/test.json",
"include": [
"tests",
],
"exclude": [
"node_modules",
"dist",
"src"
]
"include": ["tests"],
"exclude": ["node_modules", "dist", "src"]
}

View File

@@ -1,16 +1,8 @@
{
"extends": "tsconfig/base.json",
"compilerOptions": {
"outDir": "./dist",
"outDir": "./dist"
},
"include": [
"./src/**/*.ts",
"./src/**/*.tsx"
],
"exclude": [
"node_modules",
"dist",
"test",
"tests"
]
"include": ["./src/**/*.ts", "./src/**/*.tsx"],
"exclude": ["node_modules", "dist", "test", "tests"]
}

View File

@@ -1,11 +1,5 @@
{
"extends": "tsconfig/test.json",
"include": [
"tests",
],
"exclude": [
"node_modules",
"dist",
"src"
]
"include": ["tests"],
"exclude": ["node_modules", "dist", "src"]
}

View File

@@ -1,9 +1,4 @@
import fs from 'node:fs'
import { argv } from 'node:process'
fs.writeFileSync(
'./coverage/lcov.info',
fs
.readFileSync('./coverage/lcov.info', 'utf-8')
.replace(/SF:src/g, `SF:packages/${argv[2]}/src`)
)
fs.writeFileSync('./coverage/lcov.info', fs.readFileSync('./coverage/lcov.info', 'utf-8').replace(/SF:src/g, `SF:packages/${argv[2]}/src`))

View File

@@ -1,14 +1,8 @@
{
"extends": "tsconfig/base.json",
"compilerOptions": {
"outDir": "./dist",
"outDir": "./dist"
},
"include": [
"."
],
"exclude": [
"dist",
"build",
"node_modules"
]
"include": ["."],
"exclude": ["dist", "build", "node_modules"]
}

View File

@@ -2,86 +2,45 @@
"$schema": "https://turbo.build/schema.json",
"pipeline": {
"build": {
"outputs": [
"dist/**/*.js"
],
"inputs": [
"src/**/*.ts"
]
"outputs": ["dist/**/*.js"],
"inputs": ["src/**/*.ts"]
},
"build:type": {
"dependsOn": [
"^build:type"
],
"outputs": [
"dist/**/*.d.ts",
"dist/**/*.d.ts.map",
"dist/tsconfig.tsbuildinfo"
]
"dependsOn": ["^build:type"],
"outputs": ["dist/**/*.d.ts", "dist/**/*.d.ts.map", "dist/tsconfig.tsbuildinfo"]
},
"release-build": {
"dependsOn": [
"^release-build"
],
"outputs": [
"dist/**"
]
"dependsOn": ["^release-build"],
"outputs": ["dist/**"]
},
"test:unit-coverage": {
"dependsOn": [
"^build"
],
"outputs": [
"coverage/**"
]
"dependsOn": ["^build"],
"outputs": ["coverage/**"]
},
"test:unit": {
"dependsOn": [
"^build"
],
"outputs": [
"coverage/**"
]
"dependsOn": ["^build"],
"outputs": ["coverage/**"]
},
"test:integration": {
"dependsOn": [
"^build"
],
"outputs": [
"coverage/**"
]
"dependsOn": ["^build"],
"outputs": ["coverage/**"]
},
"test:test-type": {
"dependsOn": [
"^build:type"
]
"dependsOn": ["^build:type"]
},
"test:deno-unit": {
"dependsOn": [
"build",
"^build"
],
"outputs": [
"denoTestsDist/**"
]
"dependsOn": ["build", "^build"],
"outputs": ["denoTestsDist/**"]
},
"test:e2e": {
"dependsOn": [
"^build"
],
"outputs": [
"coverage/**"
]
"dependsOn": ["^build"],
"outputs": ["coverage/**"]
},
"lint": {
"dependsOn": [
"^build:type"
]
"dependsOn": ["^build:type"]
},
"fmt": {
"dependsOn": [
"^build:type"
]
"dependsOn": ["^build:type"]
},
"dev": {
"cache": false

View File

@@ -1,18 +1,10 @@
{
"entryPointStrategy": "packages",
"entryPoints": [
"packages/bot",
"packages/gateway",
"packages/rest",
"packages/types",
"packages/utils"
],
"entryPoints": ["packages/bot", "packages/gateway", "packages/rest", "packages/types", "packages/utils"],
"logger": "console",
"skipErrorChecking": true,
"out": "./website/docs/generated/",
"cleanOutputDir": false,
"plugin": [
"typedoc-plugin-markdown"
],
"plugin": ["typedoc-plugin-markdown"],
"commentStyle": "all"
}

View File

@@ -1,6 +1,3 @@
module.exports = {
presets: [
require.resolve('@docusaurus/core/lib/babel/preset'),
],
};
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
}

View File

@@ -16,4 +16,3 @@ This guide will proceed with Node.JS but you should apply the same concepts in y
## Choose A Coding Style
Discordeno provides you the option to use a Class based approach or a No-Class based approach. If you are willing to take your time and optimize your bot to the max, I highly recommend you go the No-Class route. However, this guide will use the Class based approach as I believe most users will end up choosing this route. Should you require any help with the functional approach please contact us on Discord.

View File

@@ -204,7 +204,7 @@ Having multiple bot's sending requests from one source will impact your global r
:::
```ts
const MANAGERS = new Collection<string, RestManager>();
const MANAGERS = new Collection<string, RestManager>()
```
Create this MANAGERS collection at the near the top of the file. Then we can begin implementing this in our request handler. We are going to be changing this line:
@@ -228,20 +228,19 @@ try {
const result = await manager.makeRequest(req.method, `${manager.baseUrl}${req.url}`, req.body)
```
### Evals
One of the last things we should do, is make it possible to run commands on this process. To do this, we simply create a small bot on this process with an eval command that listens for our messages only on our developer server. This way we can dynamically update any properties we may need to. For example, if discord updates the API version, we can easily switch the api version with a simple command.
Let's make a small bot on this process. Make a file called `services/rest/bot.ts`. Then paste the code below.
```ts
````ts
import { createBot } from '@discordeno/bot'
import { logger } from '@discordeno/utils'
import * as util from 'util'
const inspectOptions = {
depth: 1
depth: 1,
}
const bot = createBot({
@@ -289,9 +288,9 @@ const bot = createBot({
response.push('```')
await message.channel.createMessage(response.join('\n'))
}
}
},
},
})
```
````
Now that you have an eval command available on ur `REST` service, whenever you need to modify something quickly you can easily do so from ur developer server where this bot is. For example, should you want to switch to a newer api version, it is as simple as `.eval REST.version = xxx` where xxx is the new API version.

View File

@@ -35,7 +35,7 @@ export const REST = createRestManager({
proxy: {
baseUrl: process.env.REST_URL,
authorization: process.env.AUTHORIZATION,
}
},
})
```
@@ -78,10 +78,10 @@ You can adjust the amount of **shardsPerWorker** and **totalWorkers** to fit you
Let's make a file called `services/gateway/index.ts` and paste the following code:
```ts
import { logger } from '@discordeno/utils';
import dotenv from 'dotenv';
import express from 'express';
dotenv.config();
import { logger } from '@discordeno/utils'
import dotenv from 'dotenv'
import express from 'express'
dotenv.config()
const AUTHORIZATION = process.env.AUTHORIZATION as string
@@ -104,7 +104,7 @@ app.all('/*', async (req, res) => {
// Identify A Shard
switch (req.body.type) {
case 'REQUEST_MEMBERS': {
return await GATEWAY.requestMembers(req.body.guildId, req.body.options);
return await GATEWAY.requestMembers(req.body.guildId, req.body.options)
}
default:
logger.error(`[Shard] Unknown request received. ${JSON.stringify(req.body)}`)
@@ -166,13 +166,13 @@ Now, let's go ahead and set up the server where we will receive this and start a
Just like before, we are going to make another http listener to listen for incoming events and delegate them outwords. Make a file called `services/gateway/sharding/index.ts`
```ts
import { DiscordenoShard } from '@discordeno/gateway';
import { logger } from '@discordeno/utils';
import { Intents } from '@discordeno/types';
import events from './events.js';
import dotenv from 'dotenv';
import express from 'express';
dotenv.config();
import { DiscordenoShard } from '@discordeno/gateway'
import { logger } from '@discordeno/utils'
import { Intents } from '@discordeno/types'
import events from './events.js'
import dotenv from 'dotenv'
import express from 'express'
dotenv.config()
const AUTHORIZATION = process.env.AUTHORIZATION as string
const SHARDS = new Collection<number, DiscordenoShard>()
@@ -188,10 +188,10 @@ app.use(
app.use(express.json())
function getUrlFromShardId(totalShards: number, shardId: number) {
const urls = process.env.EVENT_HANDLER_URLS?.split(',') ?? [];
const index = totalShards % shardId;
const urls = process.env.EVENT_HANDLER_URLS?.split(',') ?? []
const index = totalShards % shardId
return urls[index] ?? urls[0];
return urls[index] ?? urls[0]
}
app.all('/*', async (req, res) => {
@@ -203,8 +203,10 @@ app.all('/*', async (req, res) => {
// Identify A Shard
switch (req.body.type) {
case 'IDENTIFY_SHARD': {
logger.info(`[Shard] identifying ${SHARDS.has(req.body.shardId) ? 'existing' : 'new'} shard (${req.body.shardId})`);
const shard = SHARDS.get(req.body.shardId) ?? new DiscordenoShard({
logger.info(`[Shard] identifying ${SHARDS.has(req.body.shardId) ? 'existing' : 'new'} shard (${req.body.shardId})`)
const shard =
SHARDS.get(req.body.shardId) ??
new DiscordenoShard({
id: req.body.shardId,
connection: {
compress: req.body.compress,
@@ -217,7 +219,7 @@ app.all('/*', async (req, res) => {
},
// TODO: Enable this in the next portion of the guide.
// events,
});
})
SHARDS.set(shard.id, shard)
await shard.identify()
@@ -384,8 +386,6 @@ Now let's enable resharding on our bot so we don't need to deal with it. Remembe
- Manual: You can also trigger this manually should you choose.
- When discord releases a new API version, updates your gateways to new version with no downtime.
### Evals
One of the last things we should do, is make it possible to run commands on this process. To do this, we simply create a small bot on this process with an eval command that listens for our messages only on our developer server. This way we can dynamically update any properties we may need to. For example, if discord updates the API version, we can easily switch the api version with a simple command.

View File

@@ -6,4 +6,3 @@
"description": "Automatically generated documentation for modules."
}
}

View File

@@ -28,6 +28,6 @@ const sidebars = {
},
],
*/
};
}
module.exports = sidebars;
module.exports = sidebars