-
-
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.
Fixes #5 - makes all commands ephemeral
- Loading branch information
Brandyn
committed
Jan 7, 2024
1 parent
7bdd2ac
commit 6b08636
Showing
6 changed files
with
209 additions
and
195 deletions.
There are no files selected for viewing
146 changes: 71 additions & 75 deletions
146
src/actions/discordComamnds/createRoleRequestMessage.js
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 |
---|---|---|
@@ -1,84 +1,80 @@ | ||
const db = require('../../database') | ||
const synchroniseUser = require('../synchronizeUser') | ||
const ts = require('../../teamspeak'); | ||
const { SlashCommandBuilder, PermissionsBitField, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js'); | ||
const db = require("../../database"); | ||
const synchroniseUser = require("../synchronizeUser"); | ||
const ts = require("../../teamspeak"); | ||
const { | ||
SlashCommandBuilder, | ||
PermissionsBitField, | ||
ActionRowBuilder, | ||
ButtonBuilder, | ||
ButtonStyle, | ||
} = require("discord.js"); | ||
|
||
class CreateRoleRequestMessageCommand { | ||
constructor() { | ||
this.public = false; | ||
this.data = new SlashCommandBuilder() | ||
.setName("createrolerequestmessage") | ||
.setDescription("Create a message for role requests") | ||
.addMentionableOption(option => | ||
option.setName("role1") | ||
.setDescription("Selectable Role") | ||
) | ||
.addMentionableOption(option => | ||
option.setName("role2") | ||
.setDescription("Selectable Role") | ||
) | ||
.addMentionableOption(option => | ||
option.setName("role3") | ||
.setDescription("Selectable Role") | ||
) | ||
.addMentionableOption(option => | ||
option.setName("role4") | ||
.setDescription("Selectable Role") | ||
) | ||
.addMentionableOption(option => | ||
option.setName("role5") | ||
.setDescription("Selectable Role") | ||
) | ||
.addMentionableOption(option => | ||
option.setName("role6") | ||
.setDescription("Selectable Role") | ||
) | ||
.addMentionableOption(option => | ||
option.setName("role7") | ||
.setDescription("Selectable Role") | ||
) | ||
} | ||
constructor() { | ||
this.public = false; | ||
this.data = new SlashCommandBuilder() | ||
.setName("createrolerequestmessage") | ||
.setDescription("Create a message for role requests") | ||
.addMentionableOption((option) => | ||
option.setName("role1").setDescription("Selectable Role") | ||
) | ||
.addMentionableOption((option) => | ||
option.setName("role2").setDescription("Selectable Role") | ||
) | ||
.addMentionableOption((option) => | ||
option.setName("role3").setDescription("Selectable Role") | ||
) | ||
.addMentionableOption((option) => | ||
option.setName("role4").setDescription("Selectable Role") | ||
) | ||
.addMentionableOption((option) => | ||
option.setName("role5").setDescription("Selectable Role") | ||
) | ||
.addMentionableOption((option) => | ||
option.setName("role6").setDescription("Selectable Role") | ||
) | ||
.addMentionableOption((option) => | ||
option.setName("role7").setDescription("Selectable Role") | ||
); | ||
} | ||
|
||
// TODO: Implement a rate limit | ||
|
||
async execute(interaction) { | ||
const roles = interaction.options._hoistedOptions; | ||
|
||
const row1 = new ActionRowBuilder() | ||
.addComponents(new ButtonBuilder() | ||
.setCustomId(roles[0].role.name) | ||
.setLabel(roles[0].role.name) | ||
.setStyle(ButtonStyle.Primary) | ||
) | ||
interaction.reply({content: "I Think You Sould", components: [row1]}) | ||
// TODO: Implement a rate limit | ||
|
||
async execute(interaction) { | ||
const roles = interaction.options._hoistedOptions; | ||
|
||
const row1 = new ActionRowBuilder().addComponents( | ||
new ButtonBuilder() | ||
.setCustomId(roles[0].role.name) | ||
.setLabel(roles[0].role.name) | ||
.setStyle(ButtonStyle.Primary) | ||
); | ||
interaction.reply({ content: "I Think You Sould", components: [row1] }); | ||
|
||
// let member; | ||
// let member; | ||
|
||
// if (interaction.options.getMentionable('user')) | ||
// if (interaction.member.permissions.has(PermissionsBitField.Flags.ManageRoles)) | ||
// member = interaction.options.getMentionable('user'); | ||
// else | ||
// interaction.reply("Sorry you don't have have permission to sync another user's roles") | ||
// else | ||
// member = interaction.member; | ||
|
||
// const tsid = await db.getTeamspeakIDByDiscordId(member.user.id) | ||
|
||
// let client; | ||
// try { | ||
// client = await ts.client.clientGetDbidFromUid(tsid) | ||
// } catch (ex) { console.log(ex) } | ||
|
||
// if (client) { | ||
// await synchroniseUser(interaction.member, tsid) | ||
// interaction.reply(`Roles of ${member.user.username} synchronized!`) | ||
// } else { | ||
// interaction.reply("Sorry I can't find that ID in teamspeak, please make sure you have connected to the server before and that you have used the ID for the correct identity. If you need help contact a member of high command.") | ||
// } | ||
|
||
} | ||
// if (interaction.options.getMentionable('user')) | ||
// if (interaction.member.permissions.has(PermissionsBitField.Flags.ManageRoles)) | ||
// member = interaction.options.getMentionable('user'); | ||
// else | ||
// interaction.reply("Sorry you don't have have permission to sync another user's roles") | ||
// else | ||
// member = interaction.member; | ||
|
||
// const tsid = await db.getTeamspeakIDByDiscordId(member.user.id) | ||
|
||
// let client; | ||
// try { | ||
// client = await ts.client.clientGetDbidFromUid(tsid) | ||
// } catch (ex) { console.log(ex) } | ||
|
||
// if (client) { | ||
// await synchroniseUser(interaction.member, tsid) | ||
// interaction.reply(`Roles of ${member.user.username} synchronized!`) | ||
// } else { | ||
// interaction.reply("Sorry I can't find that ID in teamspeak, please make sure you have connected to the server before and that you have used the ID for the correct identity. If you need help contact a member of high command.") | ||
// } | ||
} | ||
} | ||
|
||
module.exports = new CreateRoleRequestMessageCommand(); | ||
module.exports = new CreateRoleRequestMessageCommand(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,60 @@ | ||
const db = require('../../database') | ||
const synchroniseUser = require('../synchronizeUser') | ||
const ts = require('../../teamspeak'); | ||
const { SlashCommandBuilder, PermissionsBitField } = require('discord.js'); | ||
const db = require("../../database"); | ||
const synchroniseUser = require("../synchronizeUser"); | ||
const ts = require("../../teamspeak"); | ||
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js"); | ||
|
||
class SyncCommand { | ||
constructor() { | ||
this.public = true; | ||
this.data = new SlashCommandBuilder() | ||
.setName("sync") | ||
.setDescription("Forces the user to resynchronize.") | ||
.addMentionableOption(option => | ||
option.setName("user") | ||
.setDescription("The user to be synchronized") | ||
) | ||
constructor() { | ||
this.public = true; | ||
this.data = new SlashCommandBuilder() | ||
.setName("sync") | ||
.setDescription("Forces the user to resynchronize.") | ||
.addMentionableOption((option) => | ||
option.setName("user").setDescription("The user to be synchronized") | ||
); | ||
} | ||
|
||
// TODO: Implement a rate limit | ||
|
||
async execute(interaction) { | ||
let member; | ||
|
||
if (interaction.options.getMentionable("user")) | ||
if ( | ||
interaction.member.permissions.has( | ||
PermissionsBitField.Flags.ManageRoles | ||
) | ||
) | ||
member = interaction.options.getMentionable("user"); | ||
else | ||
interaction.reply( | ||
"Sorry you don't have have permission to sync another user's roles" | ||
); | ||
else member = interaction.member; | ||
|
||
const tsid = await db.getTeamspeakIDByDiscordId(member.user.id); | ||
|
||
let client; | ||
try { | ||
client = await ts.client.clientGetDbidFromUid(tsid); | ||
} catch (ex) { | ||
console.log(ex); | ||
} | ||
|
||
// TODO: Implement a rate limit | ||
|
||
async execute(interaction) { | ||
let member; | ||
|
||
if (interaction.options.getMentionable('user')) | ||
if (interaction.member.permissions.has(PermissionsBitField.Flags.ManageRoles)) | ||
member = interaction.options.getMentionable('user'); | ||
else | ||
interaction.reply("Sorry you don't have have permission to sync another user's roles") | ||
else | ||
member = interaction.member; | ||
|
||
const tsid = await db.getTeamspeakIDByDiscordId(member.user.id) | ||
|
||
let client; | ||
try { | ||
client = await ts.client.clientGetDbidFromUid(tsid) | ||
} catch (ex) { console.log(ex) } | ||
|
||
if (client) { | ||
await synchroniseUser(interaction.member, tsid) | ||
interaction.reply(`Roles of ${member.user.username} synchronized!`) | ||
} else { | ||
interaction.reply("Sorry I can't find that ID in teamspeak, please make sure you have connected to the server before and that you have used the ID for the correct identity. If you need help contact a member of high command.") | ||
} | ||
|
||
if (client) { | ||
await synchroniseUser(interaction.member, tsid); | ||
interaction.reply({ | ||
content: `Roles of ${member.user.username} synchronized!`, | ||
ephemeral: true, | ||
}); | ||
} else { | ||
interaction.reply({ | ||
content: | ||
"Sorry I can't find that ID in teamspeak, please make sure you have connected to the server before and that you have used the ID for the correct identity. If you need help contact a member of high command.", | ||
ephemeral: true, | ||
}); | ||
} | ||
} | ||
} | ||
|
||
module.exports = new SyncCommand(); | ||
module.exports = new SyncCommand(); |
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 |
---|---|---|
@@ -1,43 +1,41 @@ | ||
const db = require('../../database') | ||
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); | ||
const db = require("../../database"); | ||
const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); | ||
|
||
class SyncRoleCommand { | ||
constructor() { | ||
this.public = true; | ||
this.data = new SlashCommandBuilder() | ||
.setName("syncrole") | ||
.setDescription("Configures a role to by synchronized.") | ||
.setDefaultMemberPermissions(PermissionFlagsBits.ManageRoles) | ||
.addMentionableOption(option => | ||
option.setName("role") | ||
.setDescription("The role to be synchronized") | ||
.setRequired(true) | ||
) | ||
|
||
} | ||
async execute(interaction) { | ||
constructor() { | ||
this.public = true; | ||
this.data = new SlashCommandBuilder() | ||
.setName("syncrole") | ||
.setDescription("Configures a role to by synchronized.") | ||
.setDefaultMemberPermissions(PermissionFlagsBits.ManageRoles) | ||
.addMentionableOption((option) => | ||
option | ||
.setName("role") | ||
.setDescription("The role to be synchronized") | ||
.setRequired(true) | ||
); | ||
} | ||
async execute(interaction) { | ||
const role = interaction.options.getMentionable("role"); | ||
|
||
const role = interaction.options.getMentionable('role'); | ||
|
||
let synced = await db.getSynchronizedRoles(); | ||
console.log(synced) | ||
if (synced === undefined) { | ||
synced = [] | ||
} | ||
|
||
synced.push(role.name); | ||
await db.addSynchronizedRoles(role.name); | ||
|
||
synced = await db.getSynchronizedRoles(); | ||
console.log(synced) | ||
let syncedString = "Syncing: " | ||
synced.forEach((r, index) => { | ||
syncedString += r | ||
if (index < synced.length - 1) | ||
syncedString += ", " | ||
}) | ||
interaction.reply(syncedString) | ||
let synced = await db.getSynchronizedRoles(); | ||
console.log(synced); | ||
if (synced === undefined) { | ||
synced = []; | ||
} | ||
|
||
synced.push(role.name); | ||
await db.addSynchronizedRoles(role.name); | ||
|
||
synced = await db.getSynchronizedRoles(); | ||
console.log(synced); | ||
let syncedString = "Syncing: "; | ||
synced.forEach((r, index) => { | ||
syncedString += r; | ||
if (index < synced.length - 1) syncedString += ", "; | ||
}); | ||
interaction.reply({ content: syncedString, ephemeral: true }); | ||
} | ||
} | ||
|
||
module.exports = new SyncRoleCommand(); | ||
module.exports = new SyncRoleCommand(); |
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.