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

say command? #354

Open
wants to merge 351 commits into
base: v4
Choose a base branch
from
Open

say command? #354

wants to merge 351 commits into from

Conversation

DarthMayTriX
Copy link

const {
EmbedBuilder,
ApplicationCommandOptionType,
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
ComponentType,
} = require("discord.js");

module.exports = {
name: "say",
description: "Says a message as the bot to a channel you choose",
category: "ADMIN",
botPermissions: ["SendMessages"],
userPermissions: ["ManageMessages"],
slashCommand: {
enabled: true,
ephemeral: true,
description: "Says a message as the bot to a channel you choose",
options: [
{
name: "message",
description: "The message to be sent.",
type: 3,
required: true,
},
{
name: "channel",
description: "The channel where the message will be sent.",
type: 7,
required: false,
},
{
name: "message_id",
description: "The ID of the message to edit or reply to.",
type: 3,
required: false,
},
{
name: "edit",
description: "Whether to edit the message specified by message_id instead of sending a new message.",
type: 5,
required: false,
},
{
name: "ping",
description: "Whether to ping everyone in the channel after sending the message.",
type: 5,
required: false,
},
],
},
async execute(interaction) {
const { options } = interaction;

// Retrieve the message content
const message = options.getString("message").replace(/\n/g, '\n');

// Retrieve the channel where the message will be sent
const channel = options.getChannel("channel") || interaction.channel;

// Retrieve the message ID to edit or reply to
const message_id = options.getString("message_id");

// Retrieve whether to edit the message specified by message_id
const edit = options.getBoolean("edit");

// Retrieve whether to ping everyone in the channel after sending the message
const ping = options.getBoolean("ping");

try {
// If a message ID is provided, retrieve the message and edit or reply to it
if (message_id) {
const replyMessage = await channel.messages.fetch(message_id).catch(() => null);

  if (!replyMessage) {
    await interaction.followUp({ content: "Invalid message ID.", ephemeral: true });
  }

  if (edit) {
    await replyMessage.edit(message);
  } else {
    await replyMessage.reply({ content: `${message}\n${ping ? "@everyone" : ""}`, allowedMentions: { parse: ["everyone", "roles", "users"] } });
  }

  // Send the final reply
  await interaction.followUp({ content: edit ? "Message edited" : "Message sent", ephemeral: true });
} else {
  // If no message ID is provided, send a new message
  const taggedChannel = options.getChannel("channel");

if (taggedChannel) {
await taggedChannel.send({ content: message, allowedMentions: { parse: ["everyone", "roles", "users"] } });
if (ping) {
setTimeout(async () => {
await taggedChannel.send({ content: "@everyone", allowedMentions: { parse: ["everyone", "roles", "users"] } });
}, 2000); // wait 2 seconds before sending the second message
}
} else {
await interaction.channel.send({ content: message, allowedMentions: { parse: ["everyone", "roles", "users"] } });
if (ping) {
setTimeout(async () => {
await interaction.channel.send({ content: "@everyone", allowedMentions: { parse: ["everyone", "roles", "users"] } });
}, 2000); // wait 2 seconds before sending the second message
}
}

  // Send the final reply
  await interaction.followUp({ content: "Message sent", ephemeral: true });
}

} catch (error) {
console.error(error);
await interaction.followUp({ content: "An error occurred while processing this command.", ephemeral: true });
}
},

async messageRun(message, args, data) {
const replyEmbed = new EmbedBuilder()
.setTitle("Command Deprecated")
.setDescription("Please use the slash command instead.\n\nUsage: /say [channel] [message_id] [edit] [ping]");

return message.reply({ embeds: [replyEmbed], ephemeral: true });
},

async interactionRun(interaction) {
await this.execute(interaction);
},
};

saiteja-madha and others added 30 commits September 23, 2022 16:42
TypeError: Cannot read properties of null (reading 'toUpperCase')
    at antiMassMention (/usr/src/app/src/commands/admin/automod/anti.js:172:24)
DiscordAPIError[50035]: Invalid Form Body
user_id[NUMBER_TYPE_COERCE]: Value "w" is not snowflake.
DiscordAPIError[50001]: Missing Access
TypeError: Cannot read properties of null (reading 'has')
    at shouldModerate (/usr/src/app/src/handlers/automod.js:28:48)
Error [FetchOwnerId]: Couldn't resolve the guild ownerId to fetch the member.
DiscordAPIError[50013]: Missing Permissions
TypeError: this.safeSend is not a function
RangeError: Invalid time value
TypeError: req.client.wait is not a function
strange api key validation
rhaym-tech and others added 30 commits September 1, 2023 02:22
Fix /help: Cannot read properties of undefined (reading 'find')
Fix "Unknown Interaction" error when start a giveaway
…93e8c2d9ae450b2f9a6

[Snyk] Upgrade mongoose from 7.3.4 to 7.4.0
Fix subcommands not loading in /help embed
Fix contexts count always 0
Fix /search bug: select menu options must be >= 1
Fix move command "No matching channels found"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.