Skip to content

Commit

Permalink
more translations and move some text to embeds
Browse files Browse the repository at this point in the history
  • Loading branch information
3vorp committed Dec 19, 2023
1 parent afdb8e4 commit bc3ff21
Show file tree
Hide file tree
Showing 22 changed files with 95 additions and 70 deletions.
39 changes: 14 additions & 25 deletions lang/en-US/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,29 @@
"description": "You cannot botban yourself, a developer, or someone with administrator permissions."
}
},
"images": {
"too_big": "This image is too big to %ACTION%!",
"actions": {
"tile": "be tiled",
"palette": "take the palette of",
"compare": "compare"
},
"too_long": "This image is too long to animate!",
"max_size": "The maximum size for an image is 1024px².",
"max_length": "The maximum length for a tilesheet is 32 frames.",
"not_found": "No image was found!",
"suggestion": "Make sure you uploaded an image, replied to a valid image, used a valid image URL, or were in the correct channel."
},
"embed": {
"not_enough_arguments": "Not enough information was provided!",
"need_more_info": "You need to have either a description or title for an embed."
},
"poll": {
"ended": "This poll has ended!",
"suggestion": "Use /poll to make a poll!",
"vote": {
"counted": "Your vote has been counted!",
"counted_suggestion": "You can remove your vote by reacting again.",
"removed": "Your vote has been removed!",
"removed_suggestion": "You can add a new vote by reacting again."
},
"timeout": {
"no_type_given": "The given timeout doesn't specify which length it is!",
"example_types": "Example: `30s`, `1 min`, `10 hours`, `1 day`, `1 week`, `1 month`, `1 year`"
}
},
"stats": {
"usage": "%COMMAND% has run %USE% times.",
"top_ten": "Top 10 most used commands:",
"not_found": "The command `%COMMAND%` doesn't exist!"
},
"texture": {
"failed_search": "Texture search failed!",
"too_short": "You need at least three characters to start a texture search!",
"no_results": {
"title": "No results found!",
"description": "No results were found for %TEXTURENAME%. Have you made a typo?"
},
"no_image": {
"title": "Image not found!",
"description": "`%TEXTURENAME%` hasn't been made for %PACK% yet or is blacklisted!"
}
},
"info": {
"title": "Hi, I'm CompliBot. I was made for the Faithful Discord servers.",
"subtitle": "And I think I turned out pretty well.",
Expand Down
23 changes: 20 additions & 3 deletions lang/en-US/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,31 @@
},
"no_author": "The author of this message could not be found!"
},
"texture": {
"failed_search": "Texture search failed!",
"too_short": "You need at least three characters to start a texture search!",
"no_results": {
"title": "No results found!",
"description": "No results were found for %TEXTURENAME%. Have you made a typo?"
},
"no_image": {
"title": "Image not found!",
"description": "`%TEXTURENAME%` hasn't been made for %PACK% yet or is blacklisted!"
}
},
"image": {
"too_big": "This image is too big!",
"too_long": "This image is too long!",
"max_size": "The maximum size for an image is 1024px².",
"max_length": "The maximum length for a tilesheet is 32 frames.",
"not_found": "No image was found!",
"suggestion": "Make sure you uploaded an image, replied to a valid image, used a valid image URL, or are in the correct channel."
},
"command": "One of my developers made an error while making this command! Don't worry, the error is not on your side. Please contact <@360249987927638016>, <@473860522710794250>, or <@173336582265241601> if this keeps occurring.",
"permission": {
"notice": "You don't have permission to do that!",
"role_locked": "Only %TYPE%s can use this.",
"user_locked": "Only %USER% can use this."
},
"timeout": {
"no_type_given": "The given timeout doesn't specify which length it is!\nExample: `30s`, `1 min`, `10 hours`, `1 day`, `1 week`, `1 month`, `1 year`"
}
}
}
4 changes: 2 additions & 2 deletions src/client/interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ function hasPermission(type: PermissionType, warnUser = true): boolean {

async function ephemeralReply(options: InteractionReplyOptions) {
// it's already deferred so we delete the non-ephemeral message
await this.deleteReply();
await this.deleteReply().catch(() => {});
return this.followUp({ ...options, ephemeral: true });
}

async function complete() {
return this.reply({ content: "** **", fetchReply: true }).then((message: Message) =>
message.delete(),
);
).catch(() => {});
}

// add methods to just the base so it applies to all interaction types
Expand Down
8 changes: 7 additions & 1 deletion src/commands/bot/poll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Poll } from "@helpers/poll";
import { addSeconds, parseDate } from "@utility/dates";
import { emojis, parseID } from "@utility/emojis";
import { ChatInputCommandInteraction, EmbedBuilder, Message } from "@client";
import { colors } from "@utility/colors";

export const command: SlashCommand = {
data: new SlashCommandBuilder()
Expand Down Expand Up @@ -65,7 +66,12 @@ export const command: SlashCommand = {
if (timeoutVal !== null) {
if (parseInt(timeoutVal, 10).toString() === timeoutVal)
return interaction.reply({
content: interaction.strings().error.timeout.no_type_given,
embeds: [
new EmbedBuilder()
.setTitle(interaction.strings().command.poll.timeout.no_type_given)
.setDescription(interaction.strings().command.poll.timeout.example_types)
.setColor(colors.red),
],
ephemeral: true,
});
poll.setTimeout(addSeconds(new Date(), parseDate(timeoutVal)));
Expand Down
16 changes: 12 additions & 4 deletions src/commands/bot/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { SlashCommand, SlashCommandI } from "@interfaces/commands";
import { SlashCommandBuilder, Collection, Guild, version as djsVersion } from "discord.js";
import { EmbedBuilder, ChatInputCommandInteraction, Message } from "@client";
import axios from "axios";
import { colors } from "@utility/colors";

export const command: SlashCommand = {
data: new SlashCommandBuilder()
Expand All @@ -25,7 +26,7 @@ export const command: SlashCommand = {
.set("bot", async (interaction: ChatInputCommandInteraction) => {
// easier to get extended properties
const client = interaction.client;
const sumMembers = client.guilds.cache.reduce(
const memberCount = client.guilds.cache.reduce(
(acc: number, guild: Guild) => acc + guild.memberCount,
0,
);
Expand All @@ -47,14 +48,14 @@ export const command: SlashCommand = {
{ name: "Server Count", value: client.guilds.cache.size.toString(), inline: true },
{
name: "Memory Usage",
value: `${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} MB`,
value: `${(process.memoryUsage().heapUsed / 1048576).toFixed(2)} MB`,
inline: true,
},
{ name: "Discord Library", value: `Discord.js ${djsVersion}`, inline: true },
{ name: "Node.js", value: `${process.version}`, inline: true },
{ name: "Total Commands", value: `${client.slashCommands.size}`, inline: true },
{ name: "Commands Processed", value: `${commandCount}`, inline: true },
{ name: "Members Across Servers", value: `${sumMembers}`, inline: true },
{ name: "Members Across Servers", value: `${memberCount}`, inline: true },
)
.setFooter({
text: "Made with love",
Expand All @@ -71,7 +72,14 @@ export const command: SlashCommand = {
if (interaction.client.commandsProcessed.get(command) === undefined)
return interaction.reply({
ephemeral: true,
content: interaction.strings().command.stats.not_found.replace("%COMMAND%", command),
embeds: [
new EmbedBuilder()
.setTitle(interaction.strings().error.generic)
.setDescription(
interaction.strings().command.stats.not_found.replace("%COMMAND%", command),
)
.setColor(colors.red),
],
});

return interaction.reply({
Expand Down
4 changes: 2 additions & 2 deletions src/commands/images/animate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ export const command: SlashCommand = {
return interaction.ephemeralReply({
embeds: [
new EmbedBuilder()
.setTitle(interaction.strings().command.images.too_long)
.setDescription(interaction.strings().command.images.max_length)
.setTitle(interaction.strings().error.image.too_long)
.setDescription(interaction.strings().error.image.max_length)
.setColor(colors.red),
],
});
Expand Down
2 changes: 1 addition & 1 deletion src/commands/images/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const command: SlashCommand = {
const replyOptions = await textureComparison(interaction.client, results[0].id, display);
if (!replyOptions) {
await interaction.deleteReply();
return imageTooBig(interaction, "compare");
return imageTooBig(interaction);
}

return interaction.editReply(replyOptions).then((message: Message) => message.deleteButton());
Expand Down
2 changes: 1 addition & 1 deletion src/commands/images/palette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const command: SlashCommand = {

const [file, embed] = await paletteToAttachment(image);

if (!file || !embed) return imageTooBig(interaction, "palette");
if (!file || !embed) return imageTooBig(interaction);

await interaction
.reply({
Expand Down
2 changes: 1 addition & 1 deletion src/commands/images/tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const command: SlashCommand = {
const file = await tileToAttachment(image, { random, shape, magnify });

if (!file) {
return imageTooBig(interaction, "tile");
return imageTooBig(interaction);
}
await interaction
.editReply({
Expand Down
2 changes: 1 addition & 1 deletion src/components/buttons/image/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default {
if (!messageOptions) {
// stupid workaround for already having deferred the message
await interaction.deleteReply();
return imageTooBig(interaction, "compare");
return imageTooBig(interaction);
}

const embed = messageOptions.embeds[0] as EmbedBuilder;
Expand Down
2 changes: 1 addition & 1 deletion src/components/buttons/image/flip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default {
const image = await untile(url);
const attachment = await tileToAttachment(image, { random: "flip", magnify: true });

if (!attachment) return imageTooBig(interaction, "tile");
if (!attachment) return imageTooBig(interaction);

return interaction
.reply({
Expand Down
2 changes: 1 addition & 1 deletion src/components/buttons/image/palette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default {
if (!url) return imageNotFound(interaction);
const [file, embed] = await paletteToAttachment(url);

if (!file || !embed) return imageTooBig(interaction, "palette");
if (!file || !embed) return imageTooBig(interaction);

return interaction
.reply({
Expand Down
2 changes: 1 addition & 1 deletion src/components/buttons/image/rotate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default {
const image = await untile(url);
const attachment = await tileToAttachment(image, { random: "rotation", magnify: true });

if (!attachment) return imageTooBig(interaction, "tile");
if (!attachment) return imageTooBig(interaction);

return interaction
.reply({
Expand Down
2 changes: 1 addition & 1 deletion src/components/buttons/image/tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default {
if (!url) return imageNotFound(interaction);
const attachment = await tileToAttachment(url);

if (!attachment) return imageTooBig(interaction, "tile");
if (!attachment) return imageTooBig(interaction);

return interaction
.reply({
Expand Down
21 changes: 16 additions & 5 deletions src/components/buttons/poll/pollVote.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component } from "@interfaces/components";
import { Client, ButtonInteraction } from "@client";
import { Client, ButtonInteraction, EmbedBuilder } from "@client";
import { Poll } from "@helpers/poll";
import { colors } from "@utility/colors";

export default {
id: "pollVote",
Expand All @@ -24,13 +25,23 @@ export default {
if (poll.isAnonymous()) {
if (poll.getStatus() === "ended")
return interaction.followUp({
embeds: [
new EmbedBuilder()
.setTitle(interaction.strings().command.poll.ended)
.setDescription(interaction.strings().command.poll.suggestion)
.setColor(colors.red),
],
ephemeral: true,
content: "This poll has ended!",
});
const userVoteStatus = poll.hasVotedFor(type, id) ? "counted" : "removed";
interaction.followUp({
content: poll.hasVotedFor(type, id)
? "Your vote has been counted."
: "Your vote has been removed.",
embeds: [
new EmbedBuilder()
.setTitle(interaction.strings().command.poll.vote[userVoteStatus])
.setDescription(
interaction.strings().command.poll.vote[`${userVoteStatus}_suggestion`],
),
],
ephemeral: true,
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/menus/compareSelect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default {
if (!editOptions) {
// stupid workaround for already having deferred the message
await interaction.deleteReply();
return imageTooBig(interaction, "compare");
return imageTooBig(interaction);
}

message.edit(editOptions).then((message: Message) => message.deleteButton());
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/functions/getTexture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ export async function getTexture(interaction: Interaction, texture: Texture, pac
image = await loadImage(textureURL);
} catch (err) {
const errorEmbed = new EmbedBuilder()
.setTitle(interaction.strings().command.texture.no_image.title)
.setTitle(interaction.strings().error.texture.no_image.title)
.setDescription(
interaction
.strings()
.command.texture.no_image.description.replace("%TEXTURENAME%", texture.name)
.error.texture.no_image.description.replace("%TEXTURENAME%", texture.name)
.replace("%PACK%", name),
)
.setColor(colors.red);
Expand Down
8 changes: 4 additions & 4 deletions src/helpers/functions/parseTextureName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export default async function parseTextureName(
await interaction.ephemeralReply({
embeds: [
new EmbedBuilder()
.setTitle(interaction.strings().command.texture.failed_search)
.setDescription(interaction.strings().command.texture.too_short)
.setTitle(interaction.strings().error.texture.failed_search)
.setDescription(interaction.strings().error.texture.too_short)
.setColor(colors.red),
],
});
Expand All @@ -42,11 +42,11 @@ export default async function parseTextureName(
await interaction.ephemeralReply({
embeds: [
new EmbedBuilder()
.setTitle(interaction.strings().command.texture.no_results.title)
.setTitle(interaction.strings().error.texture.no_results.title)
.setDescription(
interaction
.strings()
.command.texture.no_results.description.replace("%TEXTURENAME%", `\`${name}\``),
.error.texture.no_results.description.replace("%TEXTURENAME%", `\`${name}\``),
)
.setColor(colors.red),
],
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/images/getImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export async function imageNotFound(
) {
return warnUser(
interaction,
interaction.strings(interaction instanceof Message).command.images.not_found,
interaction.strings(interaction instanceof Message).command.images.suggestion,
interaction.strings(interaction instanceof Message).error.image.not_found,
interaction.strings(interaction instanceof Message).error.image.suggestion,
);
}
2 changes: 1 addition & 1 deletion src/helpers/poll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export class Poll extends TimedEmbed {
options: PollOptions,
): Promise<void> {
embed.setTitle(options.question);
embed.setFooter({ text: `${this.id} | Use /poll to make a poll!` });
embed.setFooter({ text: `${this.id} | ${interaction.strings(true).command.poll.suggestion}` });
embed.addFields(
options.answersArr.map((answer: string) => ({
name: `${answer}`,
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/prefixCommandHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ export default async function prefixCommandHandler(message: Message) {
.then((message: Message) => message.deleteButton());
case "t":
const file = await tileToAttachment(url);
if (!file) return imageTooBig(message, "tile");
if (!file) return imageTooBig(message);
return message
.reply({ files: [file], components: [tileButtons] })
.then((message: Message) => message.deleteButton());
case "p":
const [attachment, embed] = await paletteToAttachment(url);
if (!attachment || !embed) return imageTooBig(message, "palette");
if (!attachment || !embed) return imageTooBig(message);
return message
.reply({ files: [attachment], embeds: [embed] })
.then((message: Message) => message.deleteButton());
Expand Down
Loading

0 comments on commit bc3ff21

Please sign in to comment.