-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from Project-Coda/dev
1.2.0
- Loading branch information
Showing
8 changed files
with
708 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
const { SlashCommandBuilder } = require('@discordjs/builders'); | ||
const mariadb = require('../db.js'); | ||
const env = require('../env.js'); | ||
const embedcreator = require('../embed.js'); | ||
const botgate = require('../utilities/botgate.js'); | ||
module.exports = { | ||
data: new SlashCommandBuilder() | ||
.setName('botgate') | ||
.setDescription('botgate command') | ||
.addSubcommand(subcommand => | ||
subcommand | ||
.setName('status') | ||
.setDescription('Get the status of the botgate'), | ||
) | ||
.addSubcommand(subcommand => | ||
subcommand | ||
.setName('set') | ||
.setDescription('Set the status of the botgate') | ||
.addBooleanOption(option => | ||
option.setName('botgate') | ||
.setDescription('Enable or disable botgate') | ||
.setRequired(true), | ||
), | ||
), | ||
async execute(interaction) { | ||
// Limit command to Founders and Mods | ||
if (!(interaction.member.roles.cache.has(env.discord.admin_role) || interaction.member.roles.cache.has(env.discord.mod_role))) { | ||
global.client.channels.cache.get(env.discord.logs_channel).send({ | ||
embeds: [ embedcreator.setembed( | ||
{ | ||
title: 'Incident Detected', | ||
description: `${interaction.member.user} tried to use the botgate command but did not have the correct role.`, | ||
color: '#e74c3c', | ||
}, | ||
)], | ||
}, | ||
); | ||
return interaction.reply({ | ||
embeds: [ embedcreator.setembed( | ||
{ | ||
title: 'Incident Reported', | ||
description: 'You do not have permission to use this command. This incident has been reported.', | ||
color: '#e74c3c', | ||
}, | ||
), | ||
], ephemeral: true, | ||
}); | ||
} | ||
const subcommand = interaction.options.getSubcommand(); | ||
if (subcommand === 'set') { | ||
if (interaction.options.get('botgate')) { | ||
const botgatevalue = interaction.options.get('botgate').value; | ||
// check if botgate setting exists | ||
db = await mariadb.getConnection(); | ||
const exists = await db.query('SELECT * FROM settings WHERE setting = ?', ['botgate']); | ||
db.end(); | ||
if (exists.length == 0) { | ||
// create botgate setting | ||
db = await mariadb.getConnection(); | ||
await db.query('INSERT INTO settings (setting, value) VALUES (?, ?)', ['botgate', 0]); | ||
db.end(); | ||
} | ||
if (botgatevalue === true) { | ||
db = await mariadb.getConnection(); | ||
db.query('UPDATE settings SET value = ? WHERE setting = ?', [1, 'botgate']); | ||
db.end(); | ||
embedcreator.alert(`Botgate Enabled by ${interaction.member.user}`); | ||
return interaction.reply({ | ||
embeds: [embedcreator.setembed({ | ||
title: 'Botgate Enabled', | ||
description: 'Botgate is now enabled.', | ||
color: '#2ecc71', | ||
})], ephemeral: true, | ||
}); | ||
} | ||
if (botgatevalue === false) { | ||
db = await mariadb.getConnection(); | ||
db.query('UPDATE settings SET value = ? WHERE setting = ?', [0, 'botgate']); | ||
db.end(); | ||
embedcreator.alert(`Botgate Disabled by ${interaction.member.user}`); | ||
return interaction.reply({ | ||
embeds: [embedcreator.setembed({ | ||
title: 'Botgate Disabled', | ||
description: 'Botgate is now disabled.', | ||
color: '#e74c3c', | ||
})], ephemeral: true, | ||
}); | ||
} | ||
} | ||
} | ||
if (subcommand === 'status') { | ||
// check if botgate is enabled | ||
botgatestatus = await botgate.status(); | ||
if (botgatestatus) { | ||
return interaction.reply({ | ||
embeds: [embedcreator.setembed({ | ||
title: 'Botgate Status', | ||
description: 'Botgate is enabled.', | ||
color: '#2ecc71', | ||
})], ephemeral: true, | ||
}); | ||
} | ||
else { | ||
return interaction.reply({ | ||
embeds: [embedcreator.setembed({ | ||
title: 'Botgate Status', | ||
description: 'Botgate is disabled.', | ||
color: '#e74c3c', | ||
})], ephemeral: true, | ||
}); | ||
} | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const { SlashCommandBuilder } = require('@discordjs/builders'); | ||
const embedcreator = require('../embed.js'); | ||
const { Chord } = require('@tonaljs/tonal'); | ||
|
||
module.exports = { | ||
data: new SlashCommandBuilder() | ||
.setName('chord') | ||
.setDescription('Get chord info') | ||
.addStringOption(option => | ||
option.setName('chord') | ||
.setDescription('Chord to get info for') | ||
.setRequired(true), | ||
), | ||
async execute(interaction) { | ||
const chord = interaction.options.get('chord').value; | ||
const chordInfo = Chord.get(chord); | ||
if (chordInfo && chordInfo.type) { | ||
console.log(chordInfo); | ||
return interaction.reply({ | ||
embeds: [embedcreator.setembed({ | ||
title: `${chordInfo.name}`, | ||
description: `**Notes:** ${chordInfo.notes.join(' ')} | ||
**Intervals:** ${chordInfo.intervals.join(' ')}`, | ||
})], | ||
}); | ||
} | ||
embedcreator.log(`${interaction.member.user} used the chord command\nparameters: ${chord}\n error: ${JSON.stringify(chordInfo)}`); | ||
return interaction.reply({ | ||
embeds: [embedcreator.setembed({ | ||
title: 'Error', | ||
description: `Could not find chord ${chord}`, | ||
color: '#e74c3c', | ||
})], | ||
}); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.