parent
985db250d9
commit
52c1420508
|
@ -61,6 +61,29 @@ export default new NamedCommand({
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
|
messageembeds: new NamedCommand({
|
||||||
|
description: "Enable or disable sending message previews.",
|
||||||
|
usage: "enable/disable",
|
||||||
|
run: "Please specify `enable` or `disable`.",
|
||||||
|
subcommands: {
|
||||||
|
true: new NamedCommand({
|
||||||
|
description: "Enable sending of message previews.",
|
||||||
|
async run({send, guild}) {
|
||||||
|
Storage.getGuild(guild!.id).messageEmbeds = true;
|
||||||
|
Storage.save();
|
||||||
|
send("Sending of message previews has been enabled.");
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
false: new NamedCommand({
|
||||||
|
description: "Disable sending of message previews.",
|
||||||
|
async run({send, guild}) {
|
||||||
|
Storage.getGuild(guild!.id).messageEmbeds = false;
|
||||||
|
Storage.save();
|
||||||
|
send("Sending of message previews has been disabled.");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}),
|
||||||
autoroles: new NamedCommand({
|
autoroles: new NamedCommand({
|
||||||
description: "Configure your server's autoroles.",
|
description: "Configure your server's autoroles.",
|
||||||
usage: "<roles...>",
|
usage: "<roles...>",
|
||||||
|
|
|
@ -2,8 +2,12 @@ import {client} from "../index";
|
||||||
import {MessageEmbed} from "discord.js";
|
import {MessageEmbed} from "discord.js";
|
||||||
import {getPrefix} from "../structures";
|
import {getPrefix} from "../structures";
|
||||||
import {getMessageByID} from "onion-lasers";
|
import {getMessageByID} from "onion-lasers";
|
||||||
|
import {Storage} from "../structures";
|
||||||
|
|
||||||
client.on("message", async (message) => {
|
client.on("message", async (message) => {
|
||||||
|
const {messageEmbeds} = Storage.getGuild(message.guild!.id);
|
||||||
|
|
||||||
|
if (messageEmbeds) {
|
||||||
// Only execute if the message is from a user and isn't a command.
|
// Only execute if the message is from a user and isn't a command.
|
||||||
if (message.content.startsWith(getPrefix(message.guild)) || message.author.bot) return;
|
if (message.content.startsWith(getPrefix(message.guild)) || message.author.bot) return;
|
||||||
const messageLink = extractFirstMessageLink(message.content);
|
const messageLink = extractFirstMessageLink(message.content);
|
||||||
|
@ -46,6 +50,7 @@ client.on("message", async (message) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return await message.channel.send(infoEmbed);
|
return await message.channel.send(infoEmbed);
|
||||||
|
} else return;
|
||||||
});
|
});
|
||||||
|
|
||||||
export function extractFirstMessageLink(message: string): [string, string, string] | null {
|
export function extractFirstMessageLink(message: string): [string, string, string] | null {
|
||||||
|
|
|
@ -79,6 +79,7 @@ class Member {
|
||||||
|
|
||||||
class Guild {
|
class Guild {
|
||||||
public prefix: string | null;
|
public prefix: string | null;
|
||||||
|
public messageEmbeds: boolean | null;
|
||||||
public welcomeType: "none" | "text" | "graphical";
|
public welcomeType: "none" | "text" | "graphical";
|
||||||
public welcomeChannel: string | null;
|
public welcomeChannel: string | null;
|
||||||
public welcomeMessage: string | null;
|
public welcomeMessage: string | null;
|
||||||
|
@ -90,6 +91,7 @@ class Guild {
|
||||||
|
|
||||||
constructor(data?: GenericJSON) {
|
constructor(data?: GenericJSON) {
|
||||||
this.prefix = select(data?.prefix, null, String);
|
this.prefix = select(data?.prefix, null, String);
|
||||||
|
this.messageEmbeds = select(data?.messageLinks, true, Boolean);
|
||||||
this.welcomeChannel = select(data?.welcomeChannel, null, String);
|
this.welcomeChannel = select(data?.welcomeChannel, null, String);
|
||||||
this.welcomeMessage = select(data?.welcomeMessage, null, String);
|
this.welcomeMessage = select(data?.welcomeMessage, null, String);
|
||||||
this.autoRoles = select(data?.autoRoles, null, String, true);
|
this.autoRoles = select(data?.autoRoles, null, String, true);
|
||||||
|
|
Loading…
Reference in New Issue