parent
38e03a85bb
commit
705e093999
|
@ -1182,9 +1182,9 @@
|
|||
"integrity": "sha512-OdjXJxnCN1AvyLSzeKIgXTXxV+99ZuXl3Hpo9XpJAv9MBcHrrJOQ5kV7ypXOuQie+AmWG25hLbiKdwYTifzcfQ=="
|
||||
},
|
||||
"typescript": {
|
||||
"version": "3.9.7",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.7.tgz",
|
||||
"integrity": "sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==",
|
||||
"version": "4.2.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.3.tgz",
|
||||
"integrity": "sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==",
|
||||
"dev": true
|
||||
},
|
||||
"which": {
|
||||
|
|
|
@ -556,6 +556,7 @@ export abstract class GenericStructure {
|
|||
|
||||
public save(asynchronous = true) {
|
||||
const tag = this.__meta__;
|
||||
/// @ts-ignore
|
||||
delete this.__meta__;
|
||||
FileManager.write(tag, this, asynchronous);
|
||||
this.__meta__ = tag;
|
||||
|
|
|
@ -4,6 +4,7 @@ import {hasPermission, getPermissionLevel, PermissionNames} from "../core/permis
|
|||
import {Permissions, Collection} from "discord.js";
|
||||
import {getPrefix} from "../core/structures";
|
||||
import $, {replyEventListeners} from "../core/lib";
|
||||
import quote from "../modules/message_embed";
|
||||
|
||||
// It's a rather hacky solution, but since there's no top-level await, I just have to make the loading conditional.
|
||||
let commands: Collection<string, Command> | null = null;
|
||||
|
@ -31,6 +32,10 @@ export default new Event<"message">({
|
|||
const clientUser = message.client.user;
|
||||
let usesBotSpecificPrefix = false;
|
||||
|
||||
if (!message.content.startsWith(prefix)) {
|
||||
return quote(message);
|
||||
}
|
||||
|
||||
// If the client user exists, check if it starts with the bot-specific prefix.
|
||||
if (clientUser) {
|
||||
// If the prefix starts with the bot-specific prefix, go off that instead (these two options must mutually exclude each other).
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
import { client } from '..'
|
||||
import { Message, TextChannel, APIMessage, MessageEmbed } from 'discord.js'
|
||||
import { getPrefix } from '../core/structures'
|
||||
import { DiscordAPIError } from 'discord.js'
|
||||
|
||||
export default async function quote(message: Message) {
|
||||
if (message.author.bot) return
|
||||
// const message_link_regex = message.content.match(/(!)?https?:\/\/\w+\.com\/channels\/(\d+)\/(\d+)\/(\d+)/)
|
||||
const message_link_regex = message.content.match(/([<!]?)https?:\/\/(?:ptb\.|canary\.|)discord(?:app)?\.com\/channels\/(\d+)\/(\d+)\/(\d+)(>?)/)
|
||||
|
||||
if (message_link_regex == null) return
|
||||
const [, char, guildID, channelID, messageID] = message_link_regex
|
||||
|
||||
if (char || message.content.startsWith(getPrefix(message.guild))) return
|
||||
|
||||
try {
|
||||
const channel = client.guilds.cache.get(guildID)?.channels.cache.get(channelID) as TextChannel
|
||||
const link_message = await channel.messages.fetch(messageID)
|
||||
|
||||
let rtmsg: string | APIMessage = ''
|
||||
if (link_message.cleanContent) {
|
||||
rtmsg = new APIMessage(message.channel as TextChannel, {
|
||||
content: link_message.cleanContent,
|
||||
disableMentions: 'all',
|
||||
files: link_message.attachments.array()
|
||||
})
|
||||
}
|
||||
|
||||
const embeds = [
|
||||
...link_message.embeds.filter(v => v.type == 'rich'),
|
||||
...link_message.attachments.values()
|
||||
]
|
||||
|
||||
/// @ts-ignore
|
||||
if (!link_message.cleanContent && embeds.empty) {
|
||||
const Embed = new MessageEmbed()
|
||||
.setDescription('🚫 The message is empty.')
|
||||
return message.channel.send(Embed)
|
||||
}
|
||||
|
||||
const infoEmbed = new MessageEmbed()
|
||||
.setAuthor(
|
||||
link_message.author.username,
|
||||
link_message.author.displayAvatarURL({format: 'png', dynamic: true, size: 4096}))
|
||||
.setTimestamp(link_message.createdTimestamp)
|
||||
.setDescription(`${link_message.cleanContent}\n\nSent in **${link_message.guild?.name}** | <#${link_message.channel.id}> ([link](https://discord.com/channels/${guildID}/${channelID}/${messageID}))`);
|
||||
if (link_message.attachments.size !== 0) {
|
||||
const image = link_message.attachments.first();
|
||||
/// @ts-ignore
|
||||
infoEmbed.setImage(image.url);
|
||||
}
|
||||
|
||||
await message.channel.send(infoEmbed)
|
||||
} catch (error) {
|
||||
if (error instanceof DiscordAPIError) {
|
||||
message.channel.send("I don't have access to this channel, or something else went wrong.")
|
||||
}
|
||||
return console.error(error)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue