Skip to content

Commit

Permalink
Merge pull request #3 from LostAndDead/dev
Browse files Browse the repository at this point in the history
Added ability to toggle polling checks
  • Loading branch information
LostAndDead authored Aug 20, 2023
2 parents 03d71de + fd7e66d commit a57de21
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/commands/info.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const { SlashCommandBuilder } = require('@discordjs/builders');

const api = require('../handlers/api.js');
const embds = require('../handlers/embeds.js');
const embeds = require('../handlers/embeds.js');

module.exports.run = async(interaction, Client) => {

var uuid = interaction.options.getString('uuid');

const file = await api.getFile(uuid);

await embds.infoEmbed(file, interaction);
await embeds.infoEmbed(file, interaction);
};

module.exports.info = new SlashCommandBuilder()
Expand Down
23 changes: 23 additions & 0 deletions src/commands/toggle_upload_check.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const { SlashCommandBuilder } = require('@discordjs/builders');

const api = require('../handlers/api.js');

module.exports.run = async(interaction, Client) => {

var value = interaction.options.getBoolean('value');

if(value == null){
api.setLoopState(!api.getLoopState());
await interaction.reply({ content: `Upload checking is now ${api.getLoopState() ? "enabled" : "disabled"}`, ephemeral: true });
}
else{
api.setLoopState(value);
await interaction.reply({ content: `Upload checking is now ${api.getLoopState() ? "enabled" : "disabled"}`, ephemeral: true });
}
};

module.exports.info = new SlashCommandBuilder()
.setName('toggle_upload_check')
.setDescription('Toggle the checking for new uploads.')
.addBooleanOption(option => option.setName('value').setDescription('If set will set the state rather than toggling it').setRequired(false))
.setDMPermission(true);
5 changes: 5 additions & 0 deletions src/handlers/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ module.exports.removeFromAlbum = async (uuid, album) => {

module.exports.setLoopState = (state) => {
checkState = state;
if(!checkState) knownFiles = [];
}

module.exports.getLoopState = () => {
return checkState;
}

module.exports.startLoop = (Client) => {
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ client.on("ready", async() => {
apiStatus = await api.checkAuth();
console.log("API Status: " + apiStatus);
api.startLoop(client);
if(apiStatus) await api.setLoopState(true);
api.setLoopState(true);
});

//Listen for commands coming from chat and context menus
Expand Down

0 comments on commit a57de21

Please sign in to comment.