Skip to content

Commit

Permalink
update submission by id
Browse files Browse the repository at this point in the history
and also remove more unused or outdated strings
  • Loading branch information
3vorp committed Jul 24, 2023
1 parent 13c028a commit ba0d147
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 31 deletions.
6 changes: 3 additions & 3 deletions commands/other/behave.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = {
ids = url.replace("/channels/", "").replace("message", "").split("/");
else if (link.startsWith("https://discordapp.com/channels/"))
ids = url.replace("/channels/", "").split("/");
else return await message.reply({ content: strings.command.behave.answer });
else return await message.reply({ content: strings.command.behave });

/** @type {Discord.TextChannel} */
const channel = message.guild.channels.cache.get(ids[1]);
Expand All @@ -29,9 +29,9 @@ module.exports = {
await message.delete();

// reply to link message
return await messageToBehave.reply({ content: strings.command.behave.answer });
return await messageToBehave.reply({ content: strings.command.behave });
}

return await message.reply({ content: strings.command.behave.answer });
return await message.reply({ content: strings.command.behave });
},
};
16 changes: 7 additions & 9 deletions functions/submission/submitTexture.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,27 @@ module.exports = async function submitTexture(client, message) {
continue;
}

// get the texture ID
let id = args
.filter((el) => el.startsWith("(#") && el.endsWith(")") && !isNaN(el.slice(2).slice(0, -1)))
.map((el) => el.slice(2).slice(0, -1))[0];

// take image url to get name of texture
const search = attachment.url.split("/").slice(-1)[0].replace(".png", "");
// try and get the texture id from the message contents
let id = (message.content.match(/(?<=\[\#)(.*?)(?=\])/) ?? [""])[0];

// get authors and description for embed
let param = {
description: message.content.replace(`(#${id})`, ""),
description: message.content.replace(`[#${id}]`, ""),
authors: await getAuthors(message),
};

// priority to ids -> faster
if (id) {
if (!isNaN(Number(id))) {
let texture = await textures
.get(id)
.catch((err) => invalidSubmission(message, strings.submission.unknown_id + err));
await makeEmbed(client, message, texture, attachment, param);
continue;
}

// if there's no id, take image url to get name of texture
const search = attachment.url.split("/").slice(-1)[0].replace(".png", "");

// if there's no search and no id the submission can't be valid
if (!search) {
await invalidSubmission(message, strings.submission.no_name_given);
Expand Down
4 changes: 2 additions & 2 deletions helpers/choiceEmbed.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ module.exports = async function (message, params, user) {

params = Object.assign({}, DEFAULT, params);

if (!params.propositions) throw new Error("No proposition in object");
if (!params.propositions) throw new Error("No choices given");

let embed = new MessageEmbed().setTitle(params.title).setColor(params.color);

if (params.imageURL) embed = embed.setFooter({ text: params.footer, iconURL: params.imageURL });
else embed = embed.setFooter({ text: params.footer });

// propositions object
// choice object
let propObj;
if (Array.isArray(params.propositions)) {
propObj = {};
Expand Down
7 changes: 1 addition & 6 deletions helpers/warnUser.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const settings = require("../resources/settings.json");
const strings = require("../resources/strings.json");
const prefix = process.env.PREFIX;

const { MessageEmbed } = require("discord.js");
const addDeleteReact = require("./addDeleteReact");
Expand All @@ -16,11 +15,7 @@ module.exports = async function warnUser(message, text) {
.setColor(settings.colors.red)
.setThumbnail(settings.images.warning)
.setTitle(strings.bot.error)
.setDescription(text)
.setFooter({
text: strings.warn_user.footer.replace("%prefix%", prefix),
iconURL: message.client.user.displayAvatarURL(),
});
.setDescription(text);

let embedMessage;
if (message.deletable) embedMessage = await message.reply({ embeds: [embed] });
Expand Down
14 changes: 3 additions & 11 deletions resources/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,12 @@
"too_wide": "The input picture is too wide!",
"cant_animate": "This texture can't be animated."
},
"use": {
"anyone": "Anyone",
"devs": "Bot Developers",
"admins": "Managers",
"mods": "Moderators",
"disabled": "Nobody (disabled)"
},
"parse_args": "You need to add a [-f= | --flag=] at the beginning of an argument!",
"behave": { "answer": "I'm so sorry! (⌯˃̶᷄ ﹏ ˂̶᷄⌯)" }
"behave": "I'm so sorry! (⌯˃̶᷄ ﹏ ˂̶᷄⌯)"
},
"submission": {
"searching": "Searching for your texture, please wait...",
"search_description": "Choose one texture using emoji reactions.\nIf you don't see what you're looking for, be more specific.\n",
"search_description": "Choose one texture using emoji reactions.\nIf you don't see what you're looking for, try submitting by texture ID.\n",
"autoreact": {
"error_title": "Auto Reaction Failed",
"error_footer": "This message will self-destruct in 30 seconds, please re-submit!"
Expand All @@ -39,9 +32,8 @@
"no_name_given": "You didn't provide a texture name!",
"timed_out": "You didn't select a valid texture in time!"
},
"warn_user": { "footer": "Type %prefix%help to get more information about commands" },
"choice_embed": {
"title": "Choose proposition",
"title": "Pick a choice",
"description": "Please choose one result using the associated reaction.\n"
}
}

0 comments on commit ba0d147

Please sign in to comment.