Fix welcome/goodbye saving

Remove images (fonts are broken)
This commit is contained in:
Jonny_Bro (Nikita) 2024-06-23 18:00:59 +05:00
parent d1a6ed597c
commit 0e38d2086c
Signed by: jonny_bro
GPG key ID: 3F1ECC04147E9BD8
5 changed files with 49 additions and 37 deletions

View file

@ -61,16 +61,16 @@ class Goodbye extends BaseCommand {
uk: client.translate("administration/goodbye:MESSAGE", null, "uk-UA"), uk: client.translate("administration/goodbye:MESSAGE", null, "uk-UA"),
ru: client.translate("administration/goodbye:MESSAGE", null, "ru-RU"), ru: client.translate("administration/goodbye:MESSAGE", null, "ru-RU"),
}), }),
)
.addBooleanOption(option =>
option
.setName("image")
.setDescription(client.translate("administration/goodbye:IMAGE"))
.setDescriptionLocalizations({
uk: client.translate("administration/goodbye:IMAGE", null, "uk-UA"),
ru: client.translate("administration/goodbye:IMAGE", null, "ru-RU"),
}),
), ),
// .addBooleanOption(option =>
// option
// .setName("image")
// .setDescription(client.translate("administration/goodbye:IMAGE"))
// .setDescriptionLocalizations({
// uk: client.translate("administration/goodbye:IMAGE", null, "uk-UA"),
// ru: client.translate("administration/goodbye:IMAGE", null, "ru-RU"),
// }),
// ),
), ),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
@ -103,13 +103,14 @@ class Goodbye extends BaseCommand {
withImage: null, withImage: null,
}; };
await guildData.markModified("plugins.goodbye");
await guildData.save(); await guildData.save();
interaction.success("administration/goodbye:DISABLED", null, { edit: true }); interaction.success("administration/goodbye:DISABLED", null, { edit: true });
} else { } else {
const channel = interaction.options.getChannel("channel") || interaction.channel; const channel = interaction.options.getChannel("channel") || interaction.channel;
const message = interaction.options.getString("message") || interaction.translate("administration/goodbye:DEFAULT_MESSAGE"); const message = interaction.options.getString("message") || interaction.translate("administration/goodbye:DEFAULT_MESSAGE");
const image = interaction.options.getBoolean("image") || false; const image = false; // interaction.options.getBoolean("image") || false;
guildData.plugins.goodbye = { guildData.plugins.goodbye = {
enabled: true, enabled: true,
@ -118,6 +119,7 @@ class Goodbye extends BaseCommand {
withImage: image, withImage: image,
}; };
await guildData.markModified("plugins.goodbye");
await guildData.save(); await guildData.save();
interaction.success("administration/goodbye:ENABLED", { interaction.success("administration/goodbye:ENABLED", {

View file

@ -61,16 +61,16 @@ class Welcome extends BaseCommand {
uk: client.translate("administration/goodbye:MESSAGE", null, "uk-UA"), uk: client.translate("administration/goodbye:MESSAGE", null, "uk-UA"),
ru: client.translate("administration/goodbye:MESSAGE", null, "ru-RU"), ru: client.translate("administration/goodbye:MESSAGE", null, "ru-RU"),
}), }),
)
.addBooleanOption(option =>
option
.setName("image")
.setDescription(client.translate("administration/goodbye:IMAGE"))
.setDescriptionLocalizations({
uk: client.translate("administration/goodbye:IMAGE", null, "uk-UA"),
ru: client.translate("administration/goodbye:IMAGE", null, "ru-RU"),
}),
), ),
// .addBooleanOption(option =>
// option
// .setName("image")
// .setDescription(client.translate("administration/goodbye:IMAGE"))
// .setDescriptionLocalizations({
// uk: client.translate("administration/goodbye:IMAGE", null, "uk-UA"),
// ru: client.translate("administration/goodbye:IMAGE", null, "ru-RU"),
// }),
// ),
), ),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
@ -103,13 +103,14 @@ class Welcome extends BaseCommand {
withImage: null, withImage: null,
}; };
await guildData.markModified("plugins.welcome");
await guildData.save(); await guildData.save();
interaction.success("administration/welcome:DISABLED", null); interaction.success("administration/welcome:DISABLED", null);
} else { } else {
const channel = interaction.options.getChannel("channel") || interaction.channel; const channel = interaction.options.getChannel("channel") || interaction.channel;
const message = interaction.options.getString("message") || interaction.translate("administration/welcome:DEFAULT_MESSAGE"); const message = interaction.options.getString("message") || interaction.translate("administration/welcome:DEFAULT_MESSAGE");
const image = interaction.options.getBoolean("image") || false; const image = false; // interaction.options.getBoolean("image") || false;
guildData.plugins.welcome = { guildData.plugins.welcome = {
enabled: true, enabled: true,
@ -118,6 +119,7 @@ class Welcome extends BaseCommand {
withImage: image, withImage: image,
}; };
await guildData.markModified("plugins.welcome");
await guildData.save(); await guildData.save();
interaction.success("administration/welcome:ENABLED", { interaction.success("administration/welcome:ENABLED", {

View file

@ -1,7 +1,9 @@
const Canvas = require("@napi-rs/canvas"), // const Canvas = require("@napi-rs/canvas"),
BaseEvent = require("../../base/BaseEvent"), // BaseEvent = require("../../base/BaseEvent"),
{ AttachmentBuilder } = require("discord.js"), // { AttachmentBuilder } = require("discord.js"),
{ applyText } = require("../../helpers/functions"); // { applyText } = require("../../helpers/functions");
const BaseEvent = require("../../base/BaseEvent");
class GuildMemberAdd extends BaseEvent { class GuildMemberAdd extends BaseEvent {
constructor() { constructor() {
@ -34,6 +36,7 @@ class GuildMemberAdd extends BaseEvent {
.replace(/{server}/g, member.guild.name) .replace(/{server}/g, member.guild.name)
.replace(/{membercount}/g, member.guild.memberCount); .replace(/{membercount}/g, member.guild.memberCount);
/*
if (guildData.plugins.welcome.withImage) { if (guildData.plugins.welcome.withImage) {
const canvas = Canvas.createCanvas(1024, 450), const canvas = Canvas.createCanvas(1024, 450),
ctx = canvas.getContext("2d"); ctx = canvas.getContext("2d");
@ -127,8 +130,9 @@ class GuildMemberAdd extends BaseEvent {
content: message, content: message,
files: [attachment], files: [attachment],
}); });
} else } else */
channel.send({ content: message });
channel.send({ content: message });
} }
} }
} }

View file

@ -1,7 +1,9 @@
const Canvas = require("@napi-rs/canvas"), // const Canvas = require("@napi-rs/canvas"),
BaseEvent = require("../../base/BaseEvent"), // BaseEvent = require("../../base/BaseEvent"),
{ AttachmentBuilder } = require("discord.js"), // { AttachmentBuilder } = require("discord.js"),
{ applyText } = require("../../helpers/functions"); // { applyText } = require("../../helpers/functions");
const BaseEvent = require("../../base/BaseEvent");
class GuildMemberRemove extends BaseEvent { class GuildMemberRemove extends BaseEvent {
constructor() { constructor() {
@ -32,6 +34,7 @@ class GuildMemberRemove extends BaseEvent {
.replace(/{server}/g, member.guild.name) .replace(/{server}/g, member.guild.name)
.replace(/{membercount}/g, member.guild.memberCount); .replace(/{membercount}/g, member.guild.memberCount);
/*
if (guildData.plugins.goodbye.withImage) { if (guildData.plugins.goodbye.withImage) {
const canvas = Canvas.createCanvas(1024, 450), const canvas = Canvas.createCanvas(1024, 450),
ctx = canvas.getContext("2d"); ctx = canvas.getContext("2d");
@ -130,8 +133,9 @@ class GuildMemberRemove extends BaseEvent {
content: message, content: message,
files: [attachment], files: [attachment],
}); });
} else } else */
channel.send({ content: message });
channel.send({ content: message });
} }
} }
} }

View file

@ -1,9 +1,9 @@
const moment = require("moment"), const moment = require("moment");
{ GlobalFonts } = require("@napi-rs/canvas"), // const { GlobalFonts } = require("@napi-rs/canvas"),
{ resolve } = require("path"); // const { resolve } = require("path");
GlobalFonts.registerFromPath(resolve("./assets/fonts/RubikMonoOne-Regular.ttf"), "RubikMonoOne"); // GlobalFonts.registerFromPath(resolve("./assets/fonts/RubikMonoOne-Regular.ttf"), "RubikMonoOne");
GlobalFonts.registerFromPath(resolve("./assets/fonts/KeepCalm-Medium.ttf"), "KeepCalm"); // GlobalFonts.registerFromPath(resolve("./assets/fonts/KeepCalm-Medium.ttf"), "KeepCalm");
module.exports = { module.exports = {
/** /**