Alyxia Sother 2021-08-15 22:42:27 +02:00 committed by Keanu
parent 73278b7e88
commit 985db250d9
Signed by: keanucode
GPG Key ID: A7431C0D513CA93B
3 changed files with 32 additions and 1 deletions

View File

@ -61,6 +61,31 @@ export default new NamedCommand({
})
})
}),
autoroles: new NamedCommand({
description: "Configure your server's autoroles.",
usage: "<roles...>",
async run({send, guild}) {
Storage.getGuild(guild!.id).autoRoles = [];
Storage.save();
send("Reset this server's autoroles.");
},
id: "role",
any: new RestCommand({
description: "The roles to set as autoroles.",
async run({send, guild, args}) {
const guildd = Storage.getGuild(guild!.id);
for (const role of args) {
if (!role.toString().match(/^<@&(\d{17,})>$/)) {
return send("Not all arguments are a role mention!");
}
const id = role.toString().match(/^<@&(\d{17,})>$/)![1];
guildd.autoRoles!.push(id);
}
Storage.save();
return send("Saved.");
}
})
}),
welcome: new NamedCommand({
description: "Configure your server's welcome settings for the bot.",
usage: "type/channel <...>",

View File

@ -16,7 +16,11 @@ function applyText(canvas: Canvas, text: string) {
}
client.on("guildMemberAdd", async (member) => {
const {welcomeType, welcomeChannel, welcomeMessage} = Storage.getGuild(member.guild.id);
const {welcomeType, welcomeChannel, welcomeMessage, autoRoles} = Storage.getGuild(member.guild.id);
if (autoRoles) {
member.roles.add(autoRoles);
}
if (welcomeChannel) {
const channel = member.guild.channels.cache.get(welcomeChannel);

View File

@ -82,6 +82,7 @@ class Guild {
public welcomeType: "none" | "text" | "graphical";
public welcomeChannel: string | null;
public welcomeMessage: string | null;
public autoRoles: string[] | null; // StringArray of role IDs
public streamingChannel: string | null;
public streamingRoles: {[role: string]: string}; // Role ID: Category Name
public channelNames: {[channel: string]: string};
@ -91,6 +92,7 @@ class Guild {
this.prefix = select(data?.prefix, null, String);
this.welcomeChannel = select(data?.welcomeChannel, null, String);
this.welcomeMessage = select(data?.welcomeMessage, null, String);
this.autoRoles = select(data?.autoRoles, null, String, true);
this.streamingChannel = select(data?.streamingChannel, null, String);
this.streamingRoles = {};
this.channelNames = {};