Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

link factotum w hackathon object #284

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions commands/essentials/init-bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ class InitBot extends Command {
option.setName('embed_colour')
.setDescription('Hex code of embed colour')
.setRequired(false))
.addStringOption(option =>
option.setName('hackathon_name')
.setDescription('Optional: Name of the hackathon')
.setRequired(false))
),
{
idHints: '1051737348502728764'
Expand All @@ -98,24 +102,37 @@ class InitBot extends Command {
async chatInputRun(interaction) {
await firebaseUtil.connect('Factotum');

await interaction.deferReply({ ephemeral: true });
// easy constants to use
var channel = interaction.channel;
const userId = interaction.user.id;
/** @type {CommandoGuild} */
const guild = interaction.guild;
const everyoneRole = interaction.guild.roles.everyone;

const botGuildRef = await firebaseUtil.getFactotumSubCol().doc(guild.id);
const botGuildRef = firebaseUtil.getFactotumSubCol().doc(guild.id);
const hackathonName = interaction.options.getString('hackathon_name') || 'unspecified hackathon';

// make sure the user had manage server permission
if (!interaction.member.permissionsIn(interaction.channel).has('ADMINISTRATOR')) {
await interaction.reply({ content: 'You do not have permissions to run this command!', ephemeral: true });
await interaction.followUp({ content: 'You do not have permissions to run this command!', ephemeral: true });
return;
}

const botGuildDoc = await botGuildRef.get();
if (botGuildDoc.exists && botGuildDoc.data().isSetUpComplete) {
await interaction.reply({ content: 'This server is already set up!', ephemeral: true });
await interaction.followUp({ content: 'This server is already set up!', ephemeral: true });
return;
}

const initBotInfoRef = firebaseUtil.getFactotumSubCol();
const duplicateQuery = await initBotInfoRef.where('hackathonName', '==', hackathonName).get();

if (!duplicateQuery.empty && hackathonName !== 'unspecified hackathon') {
await interaction.followUp({
content: `The hackathon name "${hackathonName}" is already in use. Please use a different name or leave it unspecified.`,
ephemeral: true,
});
return;
}

Expand All @@ -139,15 +156,15 @@ class InitBot extends Command {
try {
const response = await fetch(verificationRoles.url);
let res = await response.json();

// CHANGE 3
// await botGuild.setUpVerification(guild, guest, res, welcomeSupportChannel);
verification.roles = res;
verification.guestRoleID = guest;
verification.welcomeSupportChannel = welcomeSupportChannel;
} catch (error) {
console.error('error: ' + error);
interaction.reply({ content: 'An error occurred with the file upload or verification roles upload!', ephemeral: true});
await interaction.followUp({
content: 'An error occurred with the file upload or verification roles upload!',
ephemeral: true,
});
return;
}
}
Expand All @@ -167,8 +184,7 @@ class InitBot extends Command {
const embedColor = interaction.options.getString('embed_colour') || '#26fff4';

// ask the user to move our role up the list
await interaction.reply({content: 'Before we move on, could you please move my role up the role list as high as possible, this will give me the ability to assign roles!', ephemeral: true});

await interaction.followUp({content: 'Before we move on, could you please move my role up the role list as high as possible, this will give me the ability to assign roles!', ephemeral: true});
await botGuildRef.set({
verification,
embedColor,
Expand All @@ -183,10 +199,11 @@ class InitBot extends Command {
adminLog: adminLog.id,
adminConsole: adminConsole.id
},
hackathonName,
isSetUpComplete: true,
});

await interaction.followUp('The bot is set and ready to hack!');
await interaction.followUp(`The bot is set and ready to hack for ${hackathonName}!`);
discordLog(guild, '<@' + userId + '> ran init-bot!');
}

Expand Down
Loading