Skip to content

Commit

Permalink
Merge pull request AlexzanderFlores#177 from AlexzanderFlores/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
AlexzanderFlores authored Oct 9, 2021
2 parents ceced99 + 9ee4a04 commit 43a2b65
Show file tree
Hide file tree
Showing 14 changed files with 317 additions and 357 deletions.
2 changes: 2 additions & 0 deletions dist/SlashCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ class SlashCommands {
async get(guildId) {
const commands = this.getCommands(guildId);
if (commands) {
// @ts-ignore
await commands.fetch();
return commands.cache;
}
return new Map();
Expand Down
7 changes: 4 additions & 3 deletions dist/command-checks/has-roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
const CommandErrors_1 = __importDefault(require("../enums/CommandErrors"));
module.exports = (guild, command, instance, member, user, reply) => {
module.exports = async (guild, command, instance, member, user, reply) => {
if (!guild || !member) {
return true;
}
Expand All @@ -13,9 +13,10 @@ module.exports = (guild, command, instance, member, user, reply) => {
const missingRoles = [];
const missingRolesNames = [];
for (const role of roles) {
if (!member.roles.cache.has(role)) {
const realRole = await guild.roles.fetch(role);
if (realRole !== null && !member.roles.cache.has(role)) {
missingRoles.push(role);
missingRolesNames.push(guild.roles.cache.get(role)?.name);
missingRolesNames.push(realRole.name);
}
}
if (missingRoles.length) {
Expand Down
1 change: 1 addition & 0 deletions dist/commands/channelonly.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ module.exports = {
guildId: guild?.id,
command: commandName,
});
// @ts-ignore
if (results.n === 0) {
return messageHandler.get(guild, 'NOT_CHANNEL_COMMAND');
}
Expand Down
8 changes: 2 additions & 6 deletions dist/message-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
const languages_1 = __importDefault(require("./models/languages"));
const Events_1 = __importDefault(require("./enums/Events"));
const defualtMessages = require('../messages.json');
class MessageHandler {
_instance;
Expand All @@ -42,16 +41,13 @@ class MessageHandler {
if (!this._languages.includes(instance.defaultLanguage)) {
throw new Error(`The current default language defined is not supported.`);
}
instance.on(Events_1.default.DATABASE_CONNECTED, async (connection, state) => {
if (state !== 'Connected') {
return;
}
if (instance.isDBConnected()) {
const results = await languages_1.default.find();
// @ts-ignore
for (const { _id: guildId, language } of results) {
this._guildLanguages.set(guildId, language);
}
});
}
})();
}
languages() {
Expand Down
11 changes: 4 additions & 7 deletions dist/mongo.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ const results = {
2: 'Connecting',
3: 'Disconnecting',
};
const mongo = async (mongoPath, instance, dbOptions = {}) => {
await mongoose_1.default.connect(mongoPath, {
exports.default = async (mongoPath, instance, dbOptions = {}) => {
const options = {
keepAlive: true,
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false,
...dbOptions,
});
};
await mongoose_1.default.connect(mongoPath, options);
const { connection } = mongoose_1.default;
const state = results[connection.readyState] || 'Unknown';
instance.emit(Events_1.default.DATABASE_CONNECTED, connection, state);
Expand All @@ -28,4 +26,3 @@ const getMongoConnection = () => {
return mongoose_1.default.connection;
};
exports.getMongoConnection = getMongoConnection;
exports.default = mongo;
Loading

0 comments on commit 43a2b65

Please sign in to comment.