zumito-framework 1.1.36 → 1.1.38

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.
@@ -78,8 +78,8 @@ export class ZumitoFramework {
78
78
  process.exit(1);
79
79
  }
80
80
  finally {
81
- console.log('[🗄️🟢] Database connection successful');
82
81
  this.database = mongoose.connection;
82
+ console.log('[🗄️🟢] Database connection successful');
83
83
  }
84
84
  this.initializeDiscordClient();
85
85
  this.startApiServer();
@@ -134,6 +134,7 @@ export class ZumitoFramework {
134
134
  await this.registerModule(modulesFolder, file);
135
135
  }
136
136
  this.models.forEach((modelDefiniton, modelName) => {
137
+ console.log('modelDefiniton', modelDefiniton);
137
138
  const schema = new mongoose.Schema(modelDefiniton);
138
139
  this.models.set(modelName, mongoose.model(modelName, schema));
139
140
  });
@@ -228,9 +229,13 @@ export class ZumitoFramework {
228
229
  return memberPermission.has(permission);
229
230
  }
230
231
  async getGuildSettings(guildId) {
231
- let guild = await this.models.get('Guild').findOne({ guild_id: guildId });
232
+ const Guild = this.models.get('Guild');
233
+ let guild = await Guild.findOne({ guild_id: guildId }).exec();
232
234
  if (guild == null) {
233
- guild = await this.models.get('Guild').create({ guild_id: guildId });
235
+ guild = new Guild({
236
+ guild_id: guildId,
237
+ });
238
+ await guild.save();
234
239
  }
235
240
  return guild;
236
241
  }
@@ -250,6 +255,7 @@ export class ZumitoFramework {
250
255
  method = 'addStringOption';
251
256
  break;
252
257
  case 'user':
258
+ case 'member':
253
259
  method = 'addUserOption';
254
260
  break;
255
261
  case 'channel':
@@ -258,6 +264,8 @@ export class ZumitoFramework {
258
264
  case 'role':
259
265
  method = 'addRoleOption';
260
266
  break;
267
+ default:
268
+ throw new Error('Invalid argument type ' + arg.type);
261
269
  }
262
270
  slashCommand[method]((option) => {
263
271
  option.setName(arg.name);
@@ -15,7 +15,17 @@ export class InteractionCreate extends FrameworkEvent {
15
15
  commandInstance.args.forEach(arg => {
16
16
  let option = interaction.options.get(arg.name);
17
17
  if (option) {
18
- args.set(arg.name, option.value || option.user || option.role || option.channel || option.options || option.message || option.member || option.focused || option.autocomplete || option.attachment);
18
+ switch (arg.type) {
19
+ case "user":
20
+ args.set(arg.name, option.user);
21
+ break;
22
+ case "member":
23
+ args.set(arg.name, option.member);
24
+ break;
25
+ default:
26
+ args.set(arg.name, option.value || option.user || option.role || option.channel || option.options || option.message || option.member || option.focused || option.autocomplete || option.attachment);
27
+ break;
28
+ }
19
29
  }
20
30
  });
21
31
  if (![CommandType.any, CommandType.separated, CommandType.slash].includes(commandInstance.type))
@@ -69,10 +69,15 @@ export class MessageCreate extends FrameworkEvent {
69
69
  let arg = args[i];
70
70
  let type = commandInstance.args[i]?.type;
71
71
  if (type) {
72
- if (type == 'user') {
72
+ if (type == 'member' || type == 'user') {
73
73
  const member = await message.guild.members.cache.get(arg.replace(/[<@!>]/g, ''));
74
74
  if (member) {
75
- parsedArgs.set(commandInstance.args[i].name, member);
75
+ if (type == 'user') {
76
+ parsedArgs.set(commandInstance.args[i].name, member.user);
77
+ }
78
+ else {
79
+ parsedArgs.set(commandInstance.args[i].name, member);
80
+ }
76
81
  }
77
82
  else {
78
83
  return message.reply({
@@ -179,9 +179,9 @@ export class Module {
179
179
  },
180
180
  }).catch(e => {
181
181
  console.error(`[🔄🔴 ] Error loading model ${modelName} on module ${this.constructor.name}`);
182
- console.log(boxen(e + '\n' + e.name + '\n' + e.stack, { padding: 1 }));
182
+ console.error(e, e.name, e.stack);
183
183
  });
184
- this.models.set(modelName, modelDefiniton);
184
+ this.models.set(modelName, modelDefiniton.default);
185
185
  }
186
186
  }
187
187
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zumito-framework",
3
- "version": "1.1.36",
3
+ "version": "1.1.38",
4
4
  "description": "Discord.js bot framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -16,7 +16,7 @@
16
16
  "scripts": {
17
17
  "test": "echo \"Error: no test specified\" && exit 1",
18
18
  "build": "tsc",
19
- "publish": "npm publish",
19
+ "publish-npm": "npm publish",
20
20
  "docs": "typedoc --out docs src"
21
21
  },
22
22
  "author": "fernandomema",
@@ -34,7 +34,7 @@
34
34
  "error-stack-parser": "^2.1.4",
35
35
  "express": "^4.18.1",
36
36
  "leven": "^4.0.0",
37
- "mongoose": "^6.5.2",
37
+ "mongoose": "^6.6.5",
38
38
  "plop": "^3.1.1"
39
39
  },
40
40
  "devDependencies": {