Fixed bug in category command
This commit is contained in:
@@ -10,10 +10,18 @@ module.exports = {
|
|||||||
example: "categories",
|
example: "categories",
|
||||||
isPrivileged: false,
|
isPrivileged: false,
|
||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
var categories = libCore.getCategories();
|
await libCore.getCategories(async (err, categoryResults) => {
|
||||||
|
if (err) throw err;
|
||||||
|
|
||||||
|
log.DEBUG("Returned Categories: ", categoryResults);
|
||||||
|
var categories = [];
|
||||||
|
for (const record of categoryResults) {
|
||||||
|
categories.push(record.category);
|
||||||
|
}
|
||||||
|
|
||||||
await interaction.reply(
|
await interaction.reply(
|
||||||
`Categories: [${categories.join(', ')}]`
|
`Categories: [${categories}]`
|
||||||
);
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -287,10 +287,10 @@ exports.getQuotes = async function (quote_url) {
|
|||||||
* getCategories - Returns feed categories
|
* getCategories - Returns feed categories
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
exports.getCategories = function () {
|
exports.getCategories = async (callback) => {
|
||||||
feedStorage.getUniqueByKey("category", (err, results) => {
|
feedStorage.getUniqueByKey("category", (err, results) => {
|
||||||
if (err) throw err;
|
if (err) return callback(err, undefined);
|
||||||
|
|
||||||
return results
|
return callback(undefined, results);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,7 @@ class Storage {
|
|||||||
if (this.dbTable == rssFeedsTable){
|
if (this.dbTable == rssFeedsTable){
|
||||||
records.push(new RSSSourceRecord(row.id, row.title, row.link, row.category, row.guild_id, row.channel_id));
|
records.push(new RSSSourceRecord(row.id, row.title, row.link, row.category, row.guild_id, row.channel_id));
|
||||||
}
|
}
|
||||||
if (this.dbTable == rssPostsTable){
|
else {
|
||||||
records.push(rows);
|
records.push(rows);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,7 @@ class Storage {
|
|||||||
if (this.dbTable == rssFeedsTable){
|
if (this.dbTable == rssFeedsTable){
|
||||||
records.push(new RSSSourceRecord(row.id, row.title, row.link, row.category, row.guild_id, row.channel_id));
|
records.push(new RSSSourceRecord(row.id, row.title, row.link, row.category, row.guild_id, row.channel_id));
|
||||||
}
|
}
|
||||||
if (this.dbTable == rssPostsTable){
|
else {
|
||||||
records.push(rows);
|
records.push(rows);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user