Skip to content

Commit 4863ec4

Browse files
committed
refactor: move most hardcoded strings into strings.json
few other random string-related changes, and also made maintenance mode actually work properly lol
1 parent 548c2b2 commit 4863ec4

34 files changed

Lines changed: 329 additions & 153 deletions

resources/strings.json

Lines changed: 119 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,87 @@
11
{
2-
"bot": {
3-
"error": "Action Failed",
4-
"missing_interaction": "This %INTERACTION% doesn't have an event set up yet!"
2+
"global": {
3+
"error_title": "Action Failed",
4+
"error_description": "Error for the developers: ```%ERROR%```",
5+
"missing_interaction": "This %INTERACTION% doesn't have an event set up yet!",
6+
"reserved_interaction": "This interaction is reserved for %USER%!",
7+
"progress_description": "This can take some time, please wait…",
8+
"maintenance": "I'm currently under maintenance. Please try again later!",
9+
"invalid_message": "Could not find message ID %ID%!",
10+
"none": "*None*"
511
},
612
"command": {
713
"error": "One of my developers made an error while making this command! Don't worry, the error is not on your side. Please contact <@360249987927638016> or <@173336582265241601> if this keeps occurring.",
8-
"maintenance": "I'm currently under maintenance, please try again later.",
14+
"no_permission": "You don't have permission to run this command!",
915
"description": {
1016
"autopush": "Push textures from a result channel to GitHub.",
1117
"channelpush": "Send textures to result channels.",
1218
"behave": "(⌯˃̶᷄ ﹏ ˂̶᷄⌯)",
19+
"eval": "Evaluate a string of code.",
1320
"feedback": "Create a new suggestion or bug report on our GitHub bug tracker.",
1421
"backup": "Back up all files to the GitHub Database repository.",
1522
"hotfix": "Fix something (may change at any time).",
23+
"info": "General info about CompliBot Submissions.",
1624
"ping": "Pong!",
1725
"reload": "Reloads all commands.",
1826
"restart": "Restart the bot.",
1927
"say": "Make the bot say something.",
20-
"reply": "Reply to a message with the bot",
28+
"remove": "Remove files from a pack repository. This does not remove contributions or other pack-specific data.",
29+
"reply": "Reply to a message with the bot.",
2130
"shutdown": "Stops the bot.",
22-
"status": "Changes the bot's status.",
23-
"remove": "Remove files from a pack repository. This does not remove contributions or other pack-specific data."
31+
"status": "Changes the bot's status."
32+
},
33+
"feedback": {
34+
"success_bug": "Bug report received!",
35+
"success_feedback": "Feature request received!",
36+
"success_description": "Your ticket will be created shortly on GitHub. Thank you for helping us improve the bot!",
37+
"failure_title": "Feedback could not be sent!"
38+
},
39+
"remove": {
40+
"removed_single": "Successfully removed %TEXTURE% from %PACK%!",
41+
"removed_all": "Successfully removed %TEXTURE% from all packs!",
42+
"notice": "Note that this does not remove contributions or other pack-specific data.",
43+
"no_results_found": "No results found"
44+
},
45+
"push": {
46+
"autopush_download": "Downloading textures…",
47+
"autopush_pushing": "Pushing textures…",
48+
"autopush_success": "Successfully pushed all textures!",
49+
"channelpush_success": "Successfully sent all submissions!"
50+
},
51+
"shutdown": "Shutting down…",
52+
"restart": "Restarting…",
53+
"backup": {
54+
"success_title": "Database backed up!",
55+
"successful_field": "Successful",
56+
"failure_title": "Database could not be backed up.",
57+
"failure_description": "*Check developer logs for potential failure reasons!*",
58+
"failed_field": "Failed"
59+
},
60+
"ping": {
61+
"title": "Pong!",
62+
"bot_field": "Bot Latency",
63+
"api_field": "API Latency"
64+
},
65+
"behave": {
66+
"success": "I'm so sorry! (⌯˃̶᷄ ﹏ ˂̶᷄⌯)",
67+
"failure": "lol no"
68+
},
69+
"status_changed": "Bot status successfully changed!",
70+
"palette": {
71+
"title": "Palette Results",
72+
"total": "Total: %COUNT%",
73+
"list_title": "List of colors",
74+
"list_multiple": "Palette part %d",
75+
"list_singular": "Palette",
76+
"hex_multiple": "Hex part %d",
77+
"hex_singular": "Hex"
78+
},
79+
"difference": {
80+
"title": "Texture Comparison for %TEXTURE%",
81+
"description": "- Blue: Changed pixels\n- Green: Added pixels\n- Red: Removed pixels",
82+
"footer": "Algorithm made by Ewan Howell",
83+
"no_texture": "There is no existing texture to diff against!"
2484
},
25-
"feedback_sent": "Your ticket will be created shortly on GitHub. Thank you for helping us improve the bot!",
26-
"backup_failed": "At least one collection could not be backed up. Please check the developer logs for more information.",
27-
"behave": "I'm so sorry! (⌯˃̶᷄ ﹏ ˂̶᷄⌯)",
28-
"no_permission": "You don't have permission to run this command!",
29-
"invalid_message": "Could not find message id %ID%",
3085
"image": {
3186
"input_too_big": "The input picture is too big!",
3287
"output_too_big": "The output picture will be too big!"
@@ -45,23 +100,66 @@
45100
}
46101
},
47102
"submission": {
48-
"cancelled": {
49-
"error_title": "Submission Error",
50-
"error_footer": "This message will self-destruct in %SECONDS% seconds!"
103+
"error": {
104+
"title": "Submission Error",
105+
"footer": "This message will self-destruct in %SECONDS% seconds!",
106+
"unknown": "An unknown error occurred while creating the texture submission!",
107+
"no_name_given": "No texture name or ID was found in your submission message!",
108+
"does_not_exist": "The specified texture name or ID doesn't exist!",
109+
"image_not_attached": "Please attach an image to your message!",
110+
"invalid_format": "Please provide a valid `.png` file. Other file formats like `.zip` or `.tga` are currently not supported.",
111+
"already_deleted": "Could not find original submission message.",
112+
"no_result_channel": "Could not fetch corresponding result channel! Please make sure that the pack data has been set up correctly on the Faithful Studio pack page.",
113+
"timed_out": "Select menu timed out, canceling submission…"
114+
},
115+
"starpass": {
116+
"progress_title": {
117+
"singular": "Instapassing %COUNT% texture…",
118+
"plural": "Instapassing %COUNT% textures…"
119+
},
120+
"finished_title": {
121+
"singular": "Instapassed %COUNT% texture…",
122+
"plural": "Instapassed %COUNT% textures…"
123+
},
124+
"no_reason": "*No reason provided*"
51125
},
52126
"choice_embed": {
127+
"short_title": "%COUNT% results found",
128+
"long_title": "Showing 1–%SHOWN% of %COUNT% results",
53129
"description": "If you can't find what you're looking for, please be more specific!",
54130
"placeholder": "Select a texture…"
55131
},
56-
"no_result_channel": "Could not fetch corresponding result channel! Please make sure that the pack data has been set up correctly on the Faithful Studio pack page.",
57-
"image_not_attached": "Please attach an image to your message!",
58-
"invalid_format": "Please provide a valid `.png` file. Other file formats like `.zip` or `.tga` are currently not supported.",
59-
"does_not_exist": "The specified texture name or ID doesn't exist!",
60-
"no_name_given": "No texture name or ID was found in your submission message!",
132+
"field": {
133+
"author_singular": "Author",
134+
"author_plural": "Authors",
135+
"status": "Status",
136+
"mcmeta": "MCMETA",
137+
"reason": "Reason",
138+
"original_post": "Original Post"
139+
},
140+
"status": {
141+
"pending": "Pending…",
142+
"original_approved": "Passed voting!",
143+
"original_denied": "Not enough upvotes!",
144+
"results_approved": "Will be added in a future version!",
145+
"results_denied": "Failed community vote and will not be added.",
146+
"instapassed": "Instapassed by %USER%",
147+
"invalidated": "Invalidated by %USER%"
148+
},
61149
"footer": {
62-
"cant_compare": "This texture is too big to create a comparison image!",
150+
"cannot_compare": "This texture is too big to create a comparison image!",
63151
"texture_edit": "Reference | Submitted | Current",
64152
"texture_add": "Reference | Submitted"
65153
}
154+
},
155+
"github": {
156+
"commit_message": {
157+
"autopush": "Autopush passed textures from %DATE%",
158+
"instapass": "Instapass %TEXTURES% from %DATE%",
159+
"manual_push": "Manually push textures from %DATE%, executed by %USER%",
160+
"remove": "Remove %TEXTURES%, executed by %USER%",
161+
"backup": "Back up Firestorm collections from %DATE%",
162+
"manual_backup": "Manually back up Firestorm collections from %DATE%, executed by %USER%"
163+
}
66164
}
67165
}

src/commands/bot/info.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import { defineCommand } from "@interfaces/discord";
55
import { EmbedBuilder, MessageFlags, SlashCommandBuilder } from "discord.js";
66

77
export default defineCommand({
8-
data: new SlashCommandBuilder()
9-
.setName("info")
10-
.setDescription("General info about CompliBot Submissions."),
8+
data: new SlashCommandBuilder().setName("info").setDescription(strings.command.description.info),
119
async execute(interaction) {
1210
const image = settings.images.bot;
1311
const info = strings.command.info;

src/commands/bot/ping.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ export default defineCommand({
2424
const botPing = resource.message.createdTimestamp - interaction.createdTimestamp;
2525

2626
const embed = new EmbedBuilder()
27-
.setTitle("Pong!")
27+
.setTitle(strings.command.ping.title)
2828
.setDescription(`_${quote.replace("%YEAR%", String(new Date().getFullYear() + 2))}_`)
2929
.setColor(settings.colors.blue)
3030
.addFields(
31-
{ name: "Bot Latency", value: `${botPing}ms`, inline: true },
32-
{ name: "API Latency", value: `${Math.round(apiPing)}ms`, inline: true },
31+
{ name: strings.command.ping.bot_field, value: `${botPing}ms`, inline: true },
32+
{ name: strings.command.ping.api_field, value: `${Math.round(apiPing)}ms`, inline: true },
3333
);
3434

3535
return interaction.editReply({ embeds: [embed], components: addDeleteButton() });

src/commands/bot/status.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ export default defineCommand({
6666

6767
await interaction.reply({
6868
embeds: [
69-
new EmbedBuilder()
70-
.setTitle("Bot status successfully changed!")
71-
.setColor(settings.colors.green),
69+
new EmbedBuilder().setTitle(strings.command.status_changed).setColor(settings.colors.green),
7270
],
7371
components: addDeleteButton(),
7472
});

src/commands/developer/backup.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import warnUser from "@helpers/warnUser";
77
import addDeleteButton from "@helpers/addDeleteButton";
88

99
import { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits } from "discord.js";
10+
import formattedDate from "@helpers/formattedDate";
1011

1112
export default defineCommand({
1213
data: new SlashCommandBuilder()
@@ -22,32 +23,34 @@ export default defineCommand({
2223

2324
const { successfulPushes, failedPushes, commit } = await backup(
2425
interaction.client,
25-
`Manual backup executed by: ${interaction.user.displayName}`,
26+
strings.github.commit_message.manual_backup
27+
.replace("%USER%", interaction.user.displayName)
28+
.replace("%DATE%", formattedDate()),
2629
);
2730

2831
const url = `https://github.com/${settings.backup.git.org}/${settings.backup.git.repo}/${
2932
commit ? `commit/${commit}` : `tree/${settings.backup.git.branch}`
3033
}`;
3134

3235
const embed = new EmbedBuilder()
33-
.setTitle(commit ? "Database backed up!" : "Database could not be backed up.")
36+
.setTitle(strings.command.backup[commit ? "success_title" : "failure_title"])
3437
.setURL(url)
3538
.addFields(
3639
{
37-
name: "Successful",
38-
value: successfulPushes.join("\n") || "*None*",
40+
name: strings.command.backup.successful_field,
41+
value: successfulPushes.join("\n") || strings.global.none,
3942
inline: true,
4043
},
4144
{
42-
name: "Failed",
43-
value: failedPushes.join("\n") || "*None*",
45+
name: strings.command.backup.failed_field,
46+
value: failedPushes.join("\n") || strings.global.none,
4447
inline: true,
4548
},
4649
)
4750
.setColor(commit ? settings.colors.green : settings.colors.red);
4851

4952
if (!commit || failedPushes.length)
50-
embed.setDescription("*Check developer logs for potential failure reasons!*");
53+
embed.setDescription(strings.command.backup.failure_description);
5154

5255
return interaction.editReply({
5356
embeds: [embed],

src/commands/developer/behave.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ export default defineCommand({
1414
.setDMPermission(false),
1515
async execute(interaction) {
1616
if (!process.env.DEVELOPERS.includes(interaction.user.id))
17-
return interaction.reply({ content: "lol no" });
17+
return interaction.reply({ content: strings.command.behave.failure });
1818

1919
const msgID = interaction.options.getString("message");
2020

21-
if (!msgID) return interaction.reply({ content: strings.command.behave });
21+
if (!msgID) return interaction.reply({ content: strings.command.behave.success });
2222

2323
try {
2424
const message = await interaction.channel.messages.fetch(msgID);
2525
const { resource } = await interaction.reply({ content: "** **", withResponse: true });
2626
resource.message.delete();
2727

28-
return message.reply({ content: strings.command.behave });
28+
return message.reply({ content: strings.command.behave.success });
2929
} catch {
30-
return interaction.reply({ content: strings.command.behave });
30+
return interaction.reply({ content: strings.command.behave.success });
3131
}
3232
},
3333
});

src/commands/developer/eval.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { SlashCommandBuilder, PermissionFlagsBits, EmbedBuilder, MessageFlags }
99
export default defineCommand({
1010
data: new SlashCommandBuilder()
1111
.setName("eval")
12-
.setDescription("Evaluates a string of code.")
12+
.setDescription(strings.command.description.eval)
1313
.addStringOption((option) =>
1414
option.setName("code").setDescription("The code to evaluate.").setRequired(true),
1515
)

src/commands/developer/reply.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ export default defineCommand({
3939
return interaction.reply({
4040
embeds: [
4141
new EmbedBuilder()
42-
.setTitle(strings.bot.error)
43-
.setDescription(strings.command.invalid_message.replace("%ID%", replyID))
42+
.setTitle(strings.global.error_title)
43+
.setDescription(strings.global.invalid_message.replace("%ID%", replyID))
4444
.setColor(settings.colors.red),
4545
],
4646
flags: MessageFlags.Ephemeral,

src/commands/developer/restart.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default defineCommand({
1616
return warnUser(interaction, strings.command.no_permission);
1717

1818
await interaction.reply({
19-
embeds: [new EmbedBuilder().setTitle("Restarting…").setColor(settings.colors.blue)],
19+
embeds: [new EmbedBuilder().setTitle(strings.command.restart).setColor(settings.colors.blue)],
2020
});
2121

2222
interaction.client.destroy();

src/commands/developer/shutdown.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,20 @@ export default defineCommand({
2020
.setAuthor({
2121
name: "Member banned",
2222
iconURL:
23-
"https://raw.githubusercontent.com/Faithful-Resource-Pack/Branding/main/role%20icons/5%20-%20Moderator.png",
23+
"https://raw.githubusercontent.com/Faithful-Resource-Pack/Branding/main/role_icons/moderator/moderator.png",
2424
})
2525
.setDescription(`<@${interaction.user.id}> has been banned`)
26-
.addFields({ name: "Reason", value: "trying to stop me lmao" })
26+
.addFields({ name: strings.submission.field.reason, value: "trying to stop me lmao" })
2727
.setColor(settings.colors.red),
2828
],
2929
components: addDeleteButton(),
3030
});
3131
}
3232

3333
await interaction.reply({
34-
embeds: [new EmbedBuilder().setTitle("Shutting down…").setColor(settings.colors.blue)],
34+
embeds: [
35+
new EmbedBuilder().setTitle(strings.command.shutdown).setColor(settings.colors.blue),
36+
],
3537
});
3638
return process.exit();
3739
},

0 commit comments

Comments
 (0)