This repository has been archived by the owner on Jul 15, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
126 additions
and
54 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,61 @@ | ||
const announce = require("../../util/announcement"); | ||
const emoji = require("../../config.json").emojis; | ||
|
||
const devSchema = require("../../models/devSchema"); | ||
|
||
module.exports = { | ||
name: "create-announcement", | ||
startsWith: false, | ||
async execute(interaction, client, Discord) { | ||
try { | ||
const dev = await devSchema.exists({ _id: interaction.user.id }); | ||
|
||
if(!dev) { | ||
const error = new Discord.EmbedBuilder() | ||
.setColor(client.config_embeds.error) | ||
.setDescription(`${emoji.error} You do not have permission to run this command!`) | ||
|
||
await interaction.editReply({ embeds: [error], ephemeral: true }); | ||
return; | ||
} | ||
|
||
const modal = new Discord.ModalBuilder() | ||
.setCustomId(`modal-${interaction.id}`) | ||
.setTitle("Create Announcement") | ||
|
||
const modalText = new Discord.TextInputBuilder() | ||
.setCustomId(`modal-text-${interaction.id}`) | ||
.setStyle(Discord.TextInputStyle.Paragraph) | ||
.setLabel("Content") | ||
.setMinLength(10) | ||
.setMaxLength(1000) | ||
.setRequired(true) | ||
|
||
const row = new Discord.ActionRowBuilder().addComponents(modalText); | ||
|
||
modal.addComponents(row); | ||
|
||
await interaction.showModal(modal); | ||
|
||
client.on("interactionCreate", async i => { | ||
if(!i.isModalSubmit()) return; | ||
|
||
if(i.customId === `modal-${interaction.id}`) { | ||
const text = i.fields.getTextInputValue(`modal-text-${interaction.id}`); | ||
|
||
await announce(text, interaction, client, Discord); | ||
|
||
const sent = new Discord.EmbedBuilder() | ||
.setColor(client.config_embeds.default) | ||
.setDescription(`${emoji.successful} The announcement has been sent!`) | ||
|
||
await interaction.message.edit({ embeds: [sent], components: [], ephemeral: true }); | ||
|
||
await i.deferUpdate(); | ||
} | ||
}) | ||
} catch(err) { | ||
client.logButtonError(err, interaction, Discord); | ||
} | ||
} | ||
} |
30 changes: 15 additions & 15 deletions
30
src/buttons/announcement.js → src/buttons/announcements/info.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,15 +1,15 @@ | ||
module.exports = { | ||
name: "announcement", | ||
startsWith: false, | ||
async execute(interaction, client, Discord) { | ||
try { | ||
const info = new Discord.EmbedBuilder() | ||
.setColor(client.config_embeds.default) | ||
.setDescription("ℹ️ This is an official announcement made by the Global Chat Developers.") | ||
|
||
await interaction.reply({ embeds: [info], ephemeral: true }); | ||
} catch(err) { | ||
client.logButtonError(err, interaction, Discord); | ||
} | ||
} | ||
} | ||
module.exports = { | ||
name: "announcement", | ||
startsWith: false, | ||
async execute(interaction, client, Discord) { | ||
try { | ||
const info = new Discord.EmbedBuilder() | ||
.setColor(client.config_embeds.default) | ||
.setDescription("ℹ️ This is an official announcement made by the Global Chat Developers.") | ||
|
||
await interaction.reply({ embeds: [info], ephemeral: true }); | ||
} catch(err) { | ||
client.logButtonError(err, interaction, Discord); | ||
} | ||
} | ||
} |
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
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
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
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,40 @@ | ||
const emoji = require("../../config.json").emojis; | ||
|
||
const devSchema = require("../../models/devSchema"); | ||
|
||
module.exports = { | ||
name: "announcements", | ||
description: "Manage the announcement system.", | ||
options: [], | ||
default_member_permissions: null, | ||
botPermissions: [], | ||
cooldown: 60, | ||
enabled: true, | ||
hidden: true, | ||
async execute(interaction, client, Discord) { | ||
try { | ||
const dev = await devSchema.exists({ _id: interaction.user.id }); | ||
|
||
if(!dev) { | ||
const error = new Discord.EmbedBuilder() | ||
.setColor(client.config_embeds.error) | ||
.setDescription(`${emoji.error} You do not have permission to run this command!`) | ||
|
||
await interaction.editReply({ embeds: [error], ephemeral: true }); | ||
return; | ||
} | ||
|
||
const button = new Discord.ActionRowBuilder() | ||
.addComponents ( | ||
new Discord.ButtonBuilder() | ||
.setStyle(Discord.ButtonStyle.Success) | ||
.setCustomId("create-announcement") | ||
.setLabel("Create") | ||
) | ||
|
||
await interaction.editReply({ components: [button] }); | ||
} catch(err) { | ||
client.logCommandError(err, interaction, Discord); | ||
} | ||
} | ||
} |