Merge pull request #165 from ryanccn/refactors-and-improvements
This commit is contained in:
commit
387260274b
19 changed files with 129 additions and 150 deletions
|
@ -24,17 +24,15 @@ export const tagsCommand = async (
|
|||
return;
|
||||
}
|
||||
|
||||
const embed = new EmbedBuilder();
|
||||
embed.setTitle(tag.title ?? tag.name);
|
||||
embed.setDescription(tag.content);
|
||||
if (tag.color) embed.setColor(tag.color);
|
||||
if (tag.image) embed.setImage(tag.image);
|
||||
if (tag.fields) embed.setFields(tag.fields);
|
||||
|
||||
await i.reply({
|
||||
content:
|
||||
(mention ? `<@${mention.id}> ` : '') +
|
||||
(tag.text ? `**${tag.name}**\n\n` + tag.text : ''),
|
||||
embeds: tag.embed
|
||||
? [
|
||||
new EmbedBuilder(tag.embed).setFooter({
|
||||
text: `Requested by ${i.user.tag}`,
|
||||
iconURL: i.user.avatarURL() ?? undefined,
|
||||
}),
|
||||
]
|
||||
: [],
|
||||
content: mention ? `<@${mention.id}> ` : undefined,
|
||||
embeds: [embed],
|
||||
});
|
||||
};
|
||||
|
|
26
src/tags.ts
26
src/tags.ts
|
@ -1,15 +1,18 @@
|
|||
import type { EmbedData } from 'discord.js';
|
||||
|
||||
import matter from 'gray-matter';
|
||||
import { readdir, readFile } from 'fs/promises';
|
||||
import { join } from 'path';
|
||||
import { COLORS } from './constants';
|
||||
|
||||
import { type EmbedField } from 'discord.js';
|
||||
|
||||
interface Tag {
|
||||
name: string;
|
||||
aliases?: string[];
|
||||
text?: string;
|
||||
embed?: EmbedData;
|
||||
title?: string;
|
||||
color?: number;
|
||||
content: string;
|
||||
image?: string;
|
||||
fields?: EmbedField[];
|
||||
}
|
||||
|
||||
const TAG_DIR = join(process.cwd(), 'tags');
|
||||
|
@ -22,23 +25,12 @@ export const getTags = async (): Promise<Tag[]> => {
|
|||
const file = join(TAG_DIR, _file);
|
||||
const { data, content } = matter(await readFile(file));
|
||||
|
||||
if (data.embed) {
|
||||
tags.push({
|
||||
...data,
|
||||
name: _file.replace('.md', ''),
|
||||
embed: {
|
||||
...data.embed,
|
||||
description: content.trim(),
|
||||
color: COLORS[data.embed.color],
|
||||
},
|
||||
content: content.trim(),
|
||||
color: data.color ? COLORS[data.color] : undefined,
|
||||
});
|
||||
} else {
|
||||
tags.push({
|
||||
...data,
|
||||
name: _file.replace('.md', ''),
|
||||
text: content.trim(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return tags;
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
import {
|
||||
ActionRowBuilder,
|
||||
ButtonBuilder,
|
||||
ButtonStyle,
|
||||
Colors,
|
||||
EmbedBuilder,
|
||||
type Message,
|
||||
ThreadChannel,
|
||||
ReactionCollector,
|
||||
} from 'discord.js';
|
||||
|
||||
function findFirstImage(message: Message): string | undefined {
|
||||
const result = message.attachments.find((attach) => {
|
||||
return attach.contentType?.startsWith('image/');
|
||||
});
|
||||
if (result == undefined) {
|
||||
|
||||
if (result === undefined) {
|
||||
return undefined;
|
||||
} else {
|
||||
return result.url;
|
||||
|
@ -20,22 +19,20 @@ function findFirstImage(message: Message): string | undefined {
|
|||
}
|
||||
|
||||
export async function expandDiscordLink(message: Message): Promise<void> {
|
||||
if (message.author.bot && !message.author.webhookId) return;
|
||||
if (message.author.bot && !message.webhookId) return;
|
||||
|
||||
const re =
|
||||
/(https?:\/\/)?(?:canary\.|ptb\.)?discord(?:app)?\.com\/channels\/(?<server_id>\d+)\/(?<channel_id>\d+)\/(?<message_id>\d+)/g;
|
||||
/(https?:\/\/)?(?:canary\.|ptb\.)?discord(?:app)?\.com\/channels\/(?<serverId>\d+)\/(?<channelId>\d+)\/(?<messageId>\d+)/g;
|
||||
|
||||
const results = message.content.matchAll(re);
|
||||
|
||||
let n = 0;
|
||||
const resultEmbeds: EmbedBuilder[] = [];
|
||||
|
||||
for (const r of results) {
|
||||
if (n >= 3) break; // only process three previews
|
||||
if (resultEmbeds.length >= 3) break; // only process three previews
|
||||
|
||||
if (r.groups == undefined || r.groups.server_id != message.guildId)
|
||||
continue; // do not let the bot leak messages from one server to another
|
||||
if (r.groups == undefined || r.groups.serverId != message.guildId) continue; // do not let the bot leak messages from one server to another
|
||||
|
||||
const channel = await message.guild?.channels.fetch(r.groups.channel_id);
|
||||
const channel = await message.guild?.channels.fetch(r.groups.channelId);
|
||||
|
||||
if (!channel || !channel.isTextBased()) continue;
|
||||
|
||||
|
@ -50,52 +47,58 @@ export async function expandDiscordLink(message: Message): Promise<void> {
|
|||
}
|
||||
|
||||
try {
|
||||
const messageToShow = await channel.messages.fetch(r.groups.message_id);
|
||||
const originalMessage = await channel.messages.fetch(r.groups.messageId);
|
||||
|
||||
const builder = new EmbedBuilder()
|
||||
const embed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
name: `${messageToShow.author.username}#${messageToShow.author.discriminator}`,
|
||||
iconURL: messageToShow.author.displayAvatarURL(),
|
||||
name: originalMessage.author.tag,
|
||||
iconURL: originalMessage.author.displayAvatarURL(),
|
||||
})
|
||||
.setColor(Colors.Aqua)
|
||||
.setTimestamp(messageToShow.createdTimestamp)
|
||||
.setFooter({ text: `#${messageToShow.channel.name}` });
|
||||
if (messageToShow.content) {
|
||||
builder.setDescription(messageToShow.content);
|
||||
}
|
||||
if (messageToShow.attachments.size > 0) {
|
||||
let attachmentsString = '';
|
||||
messageToShow.attachments.forEach((value) => {
|
||||
attachmentsString += `[${value.name}](${value.url}) `;
|
||||
});
|
||||
.setTimestamp(originalMessage.createdTimestamp)
|
||||
.setFooter({ text: `#${originalMessage.channel.name}` });
|
||||
|
||||
builder.addFields({ name: 'Attachments', value: attachmentsString });
|
||||
|
||||
const firstImage = findFirstImage(messageToShow);
|
||||
if (firstImage != undefined) {
|
||||
builder.setImage(firstImage);
|
||||
}
|
||||
}
|
||||
|
||||
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(
|
||||
new ButtonBuilder()
|
||||
.setLabel('Jump to original message')
|
||||
.setStyle(ButtonStyle.Link)
|
||||
.setURL(messageToShow.url),
|
||||
new ButtonBuilder()
|
||||
.setCustomId('delete-message')
|
||||
.setLabel('Delete')
|
||||
.setStyle(ButtonStyle.Danger)
|
||||
embed.setDescription(
|
||||
(originalMessage.content ? originalMessage.content + '\n\n' : '') +
|
||||
`[Jump to original message](${originalMessage.url})`
|
||||
);
|
||||
|
||||
await message.reply({
|
||||
embeds: [builder],
|
||||
components: [row],
|
||||
allowedMentions: { repliedUser: false },
|
||||
if (originalMessage.attachments.size > 0) {
|
||||
embed.addFields({
|
||||
name: 'Attachments',
|
||||
value: originalMessage.attachments
|
||||
.map((att) => `[${att.name}](${att.url})`)
|
||||
.join('\n'),
|
||||
});
|
||||
n++;
|
||||
|
||||
const firstImage = findFirstImage(originalMessage);
|
||||
if (firstImage) {
|
||||
embed.setImage(firstImage);
|
||||
}
|
||||
}
|
||||
|
||||
resultEmbeds.push(embed);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
const reply = await message.reply({
|
||||
embeds: resultEmbeds,
|
||||
allowedMentions: { repliedUser: false },
|
||||
});
|
||||
|
||||
const collector = new ReactionCollector(reply, {
|
||||
filter: (reaction) => {
|
||||
return reaction.emoji.name === '❌';
|
||||
},
|
||||
time: 5 * 60 * 1000,
|
||||
});
|
||||
|
||||
collector.on('collect', async (_, user) => {
|
||||
if (user === message.author) {
|
||||
await reply.delete();
|
||||
collector.stop();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
---
|
||||
aliases: ['thanosmethod']
|
||||
embed:
|
||||
title: Binary Search - A method of finding problems with mods
|
||||
color: blue
|
||||
aliases: ['thanosmethod']
|
||||
---
|
||||
|
||||
The binary search is a way of finding a faulty thing amongst a lot of other things, without having to remove the things one-by-one. This is useful for finding a broken mod among hundreds of mods, without having to spend time testing the mods one-by-one.
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
---
|
||||
embed:
|
||||
title: Building Prism from scratch
|
||||
color: blue
|
||||
---
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
---
|
||||
aliases: ['cf', 'curse', 'cursed', 'cursedfrog']
|
||||
embed:
|
||||
title: What's wrong with CurseForge?
|
||||
color: orange
|
||||
aliases: ['cf', 'curse', 'cursed', 'cursedfrog']
|
||||
---
|
||||
|
||||
CurseForge added a new option to block third party clients like Prism Launcher from accessing mod files, and they started to enforce this option lately. We can't allow you to download those mods directly from CurseForge because of this. However, Prism Launcher offers a workaround to enable the downloading of these mods, by allowing you to download these mods from your browser and automatically importing them into the instance. We highly encourage asking authors that opted out of client downloads to stop doing so.
|
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
embed:
|
||||
title: Java Instructions
|
||||
color: orange
|
||||
---
|
||||
|
||||
Currently, Prism Launcher does not bundle Java with itself. The instructions to setup and install Java can be found [here](https://prismlauncher.org/wiki/getting-started/installing-java/).
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
---
|
||||
aliases: ['javaforgebug', 'forgebug', 'forgejavabugfix', 'forgejavabug']
|
||||
embed:
|
||||
title: Forge Bugfix
|
||||
color: yellow
|
||||
aliases: ['javaforgebug', 'forgebug', 'forgejavabugfix', 'forgejavabug']
|
||||
image: https://media.discordapp.net/attachments/1040383700845740072/1057840239751729172/Fix.png
|
||||
---
|
||||
|
||||
1. Click the instance that is broken, then select `Edit`.
|
||||
2. Choose `Version` and then click `Forge`, then click the change version button.
|
||||
3. You can then change the version, choose the latest, and click OK.
|
||||
4. You are good to go! <a:minecraftpartyparrotr:1032312401577652274>
|
||||
|
||||
https://media.discordapp.net/attachments/1040383700845740072/1057840239751729172/Fix.png
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
---
|
||||
aliases: ['legacyjava', 'ljf']
|
||||
embed:
|
||||
title: LegacyJavaFixer
|
||||
color: yellow
|
||||
---
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
---
|
||||
aliases: ['sendlog', 'logs', '🪵']
|
||||
embed:
|
||||
title: Upload Logs
|
||||
color: orange
|
||||
aliases: ['sendlog', 'logs', '🪵']
|
||||
image: https://media.discordapp.net/attachments/923671549758820434/1027408644289077268/unknown.png
|
||||
---
|
||||
Please send logs! The recommended site to upload your logs to is [mclo.gs](https://mclo.gs/).
|
||||
|
||||
https://media.discordapp.net/attachments/923671549758820434/1027408644289077268/unknown.png
|
||||
Please send logs! The recommended site to upload your logs to is [mclo.gs](https://mclo.gs/).
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
---
|
||||
aliases: ['migr', 'mmc', 'multimc']
|
||||
embed:
|
||||
title: Migrating from MultiMC
|
||||
color: orange
|
||||
aliases: ['migr', 'mmc', 'multimc']
|
||||
---
|
||||
|
||||
https://prismlauncher.org/wiki/getting-started/migrating-multimc/
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
---
|
||||
aliases: ['of', 'optimize', 'opticrap', 'notfine']
|
||||
embed:
|
||||
title: OptiFine
|
||||
color: green
|
||||
aliases: ['of', 'optimize', 'opticrap', 'notfine']
|
||||
---
|
||||
|
||||
OptiFine is known to cause problems when paired with other mods.
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
---
|
||||
aliases: ['dirs', 'locate']
|
||||
embed:
|
||||
title: Data directories
|
||||
color: blue
|
||||
aliases: ['dirs', 'locate']
|
||||
|
||||
fields:
|
||||
- name: Portable (Windows / Linux)
|
||||
value: In the PrismLauncher folder
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
---
|
||||
embed:
|
||||
title: We don't tolerate piracy!
|
||||
color: red
|
||||
---
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
---
|
||||
aliases: ['pk']
|
||||
embed:
|
||||
title: Why PluralKit?
|
||||
color: blue
|
||||
aliases: ['pk']
|
||||
---
|
||||
|
||||
Plurality is the existence of multiple self-aware entities inside the same brain.
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
---
|
||||
aliases: ['updating', 'autoupdate']
|
||||
embed:
|
||||
title: Does Prism Launcher auto-update?
|
||||
color: blue
|
||||
aliases: ['updating', 'autoupdate']
|
||||
---
|
||||
|
||||
Windows auto-updating is WIP. For now, you will need to download the installer and run it again in order to update. You will not lose your instances.
|
||||
|
||||
Prism Launcher auto-updates for macOS using the [Sparkle Framework](https://sparkle-project.org/).
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
---
|
||||
aliases: ['msvc']
|
||||
embed:
|
||||
title: vcredist is required for Prism to run Windows
|
||||
color: pink
|
||||
aliases: ['msvc']
|
||||
---
|
||||
|
||||
Like most apps on Windows, you have to install vcredist for Prism to run. Depending on what version of Prism you are using, you may need a different version.
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
---
|
||||
title: But why?
|
||||
color: purple
|
||||
aliases:
|
||||
- 'whywasprismlaunchermade'
|
||||
- 'whywasprismmade'
|
||||
- 'whywaspolymcmade'
|
||||
- 'mmcdrama'
|
||||
- 'devlauncher'
|
||||
embed:
|
||||
title: But why?
|
||||
color: purple
|
||||
---
|
||||
|
||||
https://prismlauncher.org/wiki/overview/faq/#why-did-our-community-choose-to-fork
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
---
|
||||
aliases: ['isjava8ancient', 'whyisprismforcingme']
|
||||
embed:
|
||||
title: Why does Prism Launcher ask me to change Java version?
|
||||
color: orange
|
||||
aliases: ['isjava8ancient', 'whyisprismforcingme']
|
||||
---
|
||||
|
||||
Minecraft versions before 1.17 required Java 8 and have issues with newer Java, while newer versions require Java 17, so you need to change Java version. Some people think Java 8 is very outdated, however, it's actually an LTS, meaning it's still getting updates.
|
||||
|
||||
If one of your mods is weird and requires newer Java, you can bypass this, by going to instance settings-Java and ticking 'Skip java compatibility checks', but be aware of potential issues, such as [random CMEs](https://bugs.mojang.com/browse/MC-149777).
|
Loading…
Add table
Add a link
Reference in a new issue