@somehiddenkey/discord-command-utils 1.0.3 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,20 +1,12 @@
1
1
  # DiscordUtilsLibrary
2
2
  The purpose of this Library is to hide and abstract many of the common aspects that comes with coding discord bots in javascript. The main focus is configurations as well as registering all types of commands and interactions between different guilds.
3
- ## Installation
4
- ### SSH Installation
5
- Use this if your GitHub account already has SSH access -> requires SSH key set up
3
+ ## Setup
4
+ 1. Installation
6
5
  ```bash
7
- npm install git+ssh://git@github.com/studytogether-discord/DiscordUtilsLibrary.git
6
+ npm install @somehiddenkey/discord-command-utils --registry=https://registry.npmjs.org/
8
7
  ```
9
8
 
10
- ### HTTPS Installation
11
- If you want to use HTTPS instead, you must use a GitHub Personal Access Token (classic) with repo permissions (replace "TOKEN" with your PAT)
12
- ```bash
13
- npm install "https://TOKEN@github.com/studytogether-discord/DiscordUtilsLibrary.git"
14
- ```
15
-
16
- ### Libary Import
17
- Then import it in your code
9
+ 2. Libary Import
18
10
  ```c#
19
11
  import { Something } from "DiscordUtilsLibrary";
20
12
  // or
@@ -137,7 +129,7 @@ bot.on(Events.MessageCreate, async (message) => {
137
129
  });
138
130
 
139
131
  bot.on(Events.InteractionCreate, async (interaction) =>
140
- await interactionContainer.call_interaction(message, e => consola.error(e))
132
+ await interactionContainer.call_interaction(interaction, e => consola.error(e))
141
133
  );
142
134
  ```
143
135
  ### Register slash commands to REST
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@somehiddenkey/discord-command-utils",
3
- "version": "1.0.3",
3
+ "version": "1.1.0",
4
4
  "description": "A utility library for building Discord bot commands using discord.js",
5
5
  "author": {
6
6
  "email": "k3y.throwaway@gmail.com",
@@ -1,3 +1,7 @@
1
+ import fs from 'fs';
2
+ import ConfigError from "./ConfigError.js";
3
+ import consola from 'consola';
4
+
1
5
  /**
2
6
  * @typedef {string} Snowflake
3
7
  */
@@ -22,7 +26,7 @@ export default class LocalConfig {
22
26
  this.restOptions = data.rest_options || {};
23
27
  this.activity = data.activity || {};
24
28
 
25
- if(!this.client_id)
29
+ if(!this.clientId)
26
30
  throw new ConfigError('No client_id initialized for LocalConfig');
27
31
  }
28
32
 
@@ -30,7 +34,7 @@ export default class LocalConfig {
30
34
  * Loads the JSON file and returns a GlobalConfig instance.
31
35
  * @param {string} path
32
36
  * @param {string} environment
33
- * @returns {GlobalConfig}
37
+ * @returns {LocalConfig}
34
38
  */
35
39
  static async load(path, environment) {
36
40
  var json
@@ -38,12 +42,12 @@ export default class LocalConfig {
38
42
  const raw = fs.readFileSync(path, { encoding: 'utf8', flag: 'r' });
39
43
  json = JSON.parse(raw);
40
44
  } catch (error) {
41
- consola.error(`Failed to load GlobalConfig from path: ${path}`, error);
45
+ consola.error(`Failed to load LocalConfig from path: ${path}`, error);
42
46
  throw error;
43
47
  }
44
48
  if (environment == "production")
45
- return new GlobalConfig({...json.production || json.activity});
49
+ return new LocalConfig({...json.production || json.activity});
46
50
  else
47
- return new GlobalConfig({...json.development || json.activity});
51
+ return new LocalConfig({...json.development || json.activity});
48
52
  }
49
53
  }