Merge pull request #167 from ryanccn/minor-cleanup

minor cleanup and fixes
This commit is contained in:
Sefa Eyeoglu 2023-05-29 17:07:13 +02:00 committed by GitHub
commit 005b1c8c30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 59 additions and 41 deletions

View file

@ -1,2 +1,4 @@
DISCORD_TOKEN=
DISCORD_APP=
SAY_LOGS_CHANNEL=

37
src/commands/say.ts Normal file
View file

@ -0,0 +1,37 @@
import {
CacheType,
ChatInputCommandInteraction,
EmbedBuilder,
} from 'discord.js';
export const sayCommand = async (
interaction: ChatInputCommandInteraction<CacheType>
) => {
if (!interaction.guild || !interaction.channel) return;
const content = interaction.options.getString('content', true);
await interaction.deferReply({ ephemeral: true });
const message = await interaction.channel.send(content);
await interaction.editReply('I said what you said!');
if (process.env.SAY_LOGS_CHANNEL) {
const logsChannel = await interaction.guild.channels.fetch(
process.env.SAY_LOGS_CHANNEL
);
if (!logsChannel?.isTextBased()) return;
await logsChannel.send({
embeds: [
new EmbedBuilder()
.setTitle('Say command used')
.setDescription(content)
.setAuthor({
name: interaction.user.tag,
iconURL: interaction.user.avatarURL() ?? undefined,
})
.setURL(message.url),
],
});
}
};

View file

@ -24,6 +24,3 @@ export const COLORS = {
yellow: 0xfde047,
orange: 0xfb923c,
} as { [key: string]: number };
/* CHANGEME */
export const ALLOWED_ROLES = ['Alert', 'Events', 'Progress'];

View file

@ -4,6 +4,7 @@ import {
Partials,
OAuth2Scopes,
InteractionType,
PermissionFlagsBits,
} from 'discord.js';
import { reuploadCommands } from './_reupload';
@ -18,6 +19,7 @@ import { modrinthCommand } from './commands/modrinth';
import { tagsCommand } from './commands/tags';
import { jokeCommand } from './commands/joke';
import { roryCommand } from './commands/rory';
import { sayCommand } from './commands/say';
import random from 'just-random';
import { green, bold, yellow, cyan } from 'kleur/colors';
@ -32,7 +34,7 @@ const client = new Client({
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildBans,
GatewayIntentBits.GuildModeration,
],
partials: [Partials.Channel],
});
@ -45,21 +47,21 @@ client.once('ready', async () => {
client.generateInvite({
scopes: [OAuth2Scopes.Bot],
permissions: [
'AddReactions',
'ViewChannel',
'BanMembers',
'KickMembers',
'CreatePublicThreads',
'CreatePrivateThreads',
'EmbedLinks',
'ManageChannels',
'ManageRoles',
'ModerateMembers',
'MentionEveryone',
'MuteMembers',
'SendMessages',
'SendMessagesInThreads',
'ReadMessageHistory',
PermissionFlagsBits.AddReactions,
PermissionFlagsBits.ViewChannel,
PermissionFlagsBits.BanMembers,
PermissionFlagsBits.KickMembers,
PermissionFlagsBits.CreatePublicThreads,
PermissionFlagsBits.CreatePrivateThreads,
PermissionFlagsBits.EmbedLinks,
PermissionFlagsBits.ManageChannels,
PermissionFlagsBits.ManageRoles,
PermissionFlagsBits.ModerateMembers,
PermissionFlagsBits.MentionEveryone,
PermissionFlagsBits.MuteMembers,
PermissionFlagsBits.SendMessages,
PermissionFlagsBits.SendMessagesInThreads,
PermissionFlagsBits.ReadMessageHistory,
],
})
)
@ -98,22 +100,6 @@ client.once('ready', async () => {
});
client.on('interactionCreate', async (interaction) => {
if (interaction.isButton() && interaction.customId === 'delete-message') {
const messageRef = interaction.message.reference?.messageId;
if (messageRef) {
const msg = await interaction.message.channel.messages.fetch(messageRef);
if (interaction?.user === msg.author) {
await interaction.message.delete();
} else {
await interaction.reply({
content: 'You can only delete your own messages!',
ephemeral: true,
});
}
}
}
if (interaction.isChatInputCommand()) {
const { commandName } = interaction;
@ -129,11 +115,7 @@ client.on('interactionCreate', async (interaction) => {
} else if (commandName === 'modrinth') {
await modrinthCommand(interaction);
} else if (commandName === 'say') {
if (!interaction.channel) return;
await interaction.deferReply({ ephemeral: true });
await interaction.channel.send(interaction.options.getString('content')!);
await interaction.editReply('I said what you said!');
await sayCommand(interaction);
} else if (commandName === 'tag') {
await tagsCommand(interaction);
} else if (commandName === 'joke') {