Removed legacy subscription method
I don't really want to have to include support for it
This commit is contained in:
parent
8eb30b6d15
commit
f4a8a40cd5
|
@ -6,9 +6,7 @@
|
||||||
"messageDeleteDelay": 10000,
|
"messageDeleteDelay": 10000,
|
||||||
"youtubeMode": true,
|
"youtubeMode": true,
|
||||||
"allowSubscriptions": true,
|
"allowSubscriptions": true,
|
||||||
"legacySubscriptions": false,
|
|
||||||
"subscribersRoleID": "268153160273625088",
|
"subscribersRoleID": "268153160273625088",
|
||||||
"legacySubscribersFile": "./subscribers.json",
|
|
||||||
"logFile": "./log",
|
"logFile": "./log",
|
||||||
"userCommands": {
|
"userCommands": {
|
||||||
"subscribe": "!subscribe",
|
"subscribe": "!subscribe",
|
||||||
|
|
47
feed-bot.js
47
feed-bot.js
|
@ -106,7 +106,7 @@ var DiscordClient = {
|
||||||
//send a messsage containing the new feed link to our discord channel
|
//send a messsage containing the new feed link to our discord channel
|
||||||
DiscordClient.bot.sendMessage({
|
DiscordClient.bot.sendMessage({
|
||||||
to: Config.channelID,
|
to: Config.channelID,
|
||||||
message: "<@" + Config.subscribersRole + ">" + link
|
message: Subscriptions.mention() + link
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
//actions to perform when certain messages are detected, along with channel or user requirements
|
//actions to perform when certain messages are detected, along with channel or user requirements
|
||||||
|
@ -121,17 +121,6 @@ var DiscordClient = {
|
||||||
action: (user, userID, channelID, message) => { if (Config.allowSubscriptions) Subscriptions.unsubscribe(user, userID, channelID, message); },
|
action: (user, userID, channelID, message) => { if (Config.allowSubscriptions) Subscriptions.unsubscribe(user, userID, channelID, message); },
|
||||||
channelID: Config.channelID
|
channelID: Config.channelID
|
||||||
},
|
},
|
||||||
{
|
|
||||||
message: Config.userCommands.subscribersList,
|
|
||||||
action: (user, userID, channelID, message) => {
|
|
||||||
if (Config.allowSubscriptions && Config.legacySubscriptions)
|
|
||||||
DiscordClient.bot.sendMessage({
|
|
||||||
to: Config.channelID,
|
|
||||||
message: DiscordClient.bot.fixMessage("<@" + Subscriptions.subscribers.join("> <@") + ">")
|
|
||||||
}, (err, response) => { setTimeout(() => { DiscordClient.bot.deleteMessage({ channelID: channelID, messageID: response.id }); }, Config.messageDeleteDelay); });
|
|
||||||
},
|
|
||||||
channelID: Config.channelID
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
message: Config.userCommands.help,
|
message: Config.userCommands.help,
|
||||||
action: (user, userID, channelID, message) => {
|
action: (user, userID, channelID, message) => {
|
||||||
|
@ -166,21 +155,11 @@ var DiscordClient = {
|
||||||
};
|
};
|
||||||
|
|
||||||
var Subscriptions = {
|
var Subscriptions = {
|
||||||
parse: function () {
|
|
||||||
JsonFile.readFile(Config.legacySubscribersFile, (err, obj) => {
|
|
||||||
if (err) Log.error("Unable to parse json subscribers file", err);
|
|
||||||
this.subscribers = obj || [];
|
|
||||||
});
|
|
||||||
},
|
|
||||||
subscribe: function (user, userID, channelID, message) {
|
subscribe: function (user, userID, channelID, message) {
|
||||||
if (Config.legacySubscriptions)
|
|
||||||
this.legacy.subscribe();
|
|
||||||
else {
|
|
||||||
DiscordClient.bot.addToRole({
|
DiscordClient.bot.addToRole({
|
||||||
userID: userID,
|
userID: userID,
|
||||||
roleID: Config.subscribersRoleID
|
roleID: Config.subscribersRoleID
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
Log.event("Subscribed user " + (user ? user + "(" + userID + ")" : userID));
|
Log.event("Subscribed user " + (user ? user + "(" + userID + ")" : userID));
|
||||||
|
|
||||||
|
@ -189,10 +168,8 @@ var Subscriptions = {
|
||||||
message: "You have successfully subscribed"
|
message: "You have successfully subscribed"
|
||||||
}, (err, response) => { setTimeout(() => { DiscordClient.bot.deleteMessage({ channelID: channelID, messageID: response.id }); }, Config.messageDeleteDelay); });
|
}, (err, response) => { setTimeout(() => { DiscordClient.bot.deleteMessage({ channelID: channelID, messageID: response.id }); }, Config.messageDeleteDelay); });
|
||||||
},
|
},
|
||||||
|
|
||||||
unsubscribe: function (user, userID, channelID, message) {
|
unsubscribe: function (user, userID, channelID, message) {
|
||||||
if (Config.legacySubscriptions)
|
|
||||||
this.legacy.unsubscribe();
|
|
||||||
else
|
|
||||||
DiscordClient.bot.removeFromRole({
|
DiscordClient.bot.removeFromRole({
|
||||||
userID: userID,
|
userID: userID,
|
||||||
roleID: Config.subscribersRoleID
|
roleID: Config.subscribersRoleID
|
||||||
|
@ -205,23 +182,9 @@ var Subscriptions = {
|
||||||
message: "You have successfully unsubscribed"
|
message: "You have successfully unsubscribed"
|
||||||
}, (err, response) => { setTimeout(() => { DiscordClient.bot.deleteMessage({ channelID: channelID, messageID: response.id }); }, Config.messageDeleteDelay); });
|
}, (err, response) => { setTimeout(() => { DiscordClient.bot.deleteMessage({ channelID: channelID, messageID: response.id }); }, Config.messageDeleteDelay); });
|
||||||
},
|
},
|
||||||
legacy: {
|
|
||||||
subscribers: [],
|
mention: function () {
|
||||||
subscribe: function (user, userID, channelID, message) {
|
return "<@" + Config.subscribersRole + "> ";
|
||||||
if (this.subscribers.indexOf(userID) === -1) {
|
|
||||||
this.subscribers.push(userID); //subscribe the user if they aren't already subscribed
|
|
||||||
this.writeToFile();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
unsubscribe: function (user, userID, channelID, message) {
|
|
||||||
if (this.subscribers.indexOf(userID) > -1) {
|
|
||||||
this.subscribers.splice(this.subscribers.indexOf(userID), 1);
|
|
||||||
this.writeToFile();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
writeToFile: function () {
|
|
||||||
JsonFile.writeFile(Config.legacySubscribersFile, this.subscribers, (err) => { if (err) Log.error("Unable to write subscribers to json file", err); });
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue