locale/formatting stuff
This commit is contained in:
parent
e5cc109895
commit
5a2cf70479
@ -40,6 +40,10 @@ class GuildWrapper {
|
|||||||
return JSON.parse(JSON.stringify(this.client.defaultConfig()));
|
return JSON.parse(JSON.stringify(this.client.defaultConfig()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get locale() {
|
||||||
|
return this._settings?.locale || 'en_us';
|
||||||
|
}
|
||||||
|
|
||||||
// Logging
|
// Logging
|
||||||
|
|
||||||
_storageLog(log) {
|
_storageLog(log) {
|
||||||
|
@ -23,23 +23,35 @@ class InteractionWrapper {
|
|||||||
async reply(options = {}) {
|
async reply(options = {}) {
|
||||||
|
|
||||||
if (options.emoji) this.emojify(options);
|
if (options.emoji) this.emojify(options);
|
||||||
|
if (options.template) {
|
||||||
|
const { template } = options;
|
||||||
|
options.content = this.format(template.index, template.params, template.opts);
|
||||||
|
}
|
||||||
this._pending = await this.interaction.reply(options);
|
this._pending = await this.interaction.reply(options);
|
||||||
return this._pending;
|
return this._pending;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async editReply(options = {}) {
|
async editReply(options = {}) {
|
||||||
|
|
||||||
if (options.emoji) this.emojify(options);
|
if (options.emoji) this.emojify(options);
|
||||||
|
if (options.template) {
|
||||||
|
const { template } = options;
|
||||||
|
options.content = this.format(template.index, template.params, template.opts);
|
||||||
|
}
|
||||||
this._pending = await this.interaction.editReply(options);
|
this._pending = await this.interaction.editReply(options);
|
||||||
return this._pending;
|
return this._pending;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
format(locale, parameters = {}, code = false) {
|
format(index, parameters = {}, opts = {}) {
|
||||||
const language = 'en_us'; //Default language.
|
const {
|
||||||
|
code = false,
|
||||||
|
language = this.user.locale || this.guild?.locale || 'en_us'
|
||||||
|
} = opts;
|
||||||
|
//const language = this.guild?.locale || 'en_us'; //Default to en_us
|
||||||
//TODO: Fetch guild/user settings and switch localization.
|
//TODO: Fetch guild/user settings and switch localization.
|
||||||
return this.client.localeLoader.format(language, locale, parameters, code);
|
return this.client.localeLoader.format(language, index, parameters, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
get channel() {
|
get channel() {
|
||||||
|
@ -87,7 +87,7 @@ class CommandHandler extends Observer {
|
|||||||
const { command, interaction } = thing;
|
const { command, interaction } = thing;
|
||||||
|
|
||||||
if(!interaction.guild && command.guildOnly) {
|
if(!interaction.guild && command.guildOnly) {
|
||||||
return thing.reply({ locale: 'O_COMMANDHANDLER_GUILDONLY', emoji: 'failure', ephemeral: true });
|
return thing.reply({ template: { index: 'O_COMMANDHANDLER_GUILDONLY' }, emoji: 'failure', ephemeral: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
let error = null;
|
let error = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user