-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: config files for sapphire/i18n * feat: i18n for misc commands * fix: cancelgame change file name * feat: redefinition of locales getters with t function, games commands i18n * fix: use of args.t for i18n in misc commands * feat: i18n for roles related commands * feat: i18n for listeners and preconditions * refactor: preconditions names * feat: i18n for utils * fix: replace Users for username strings in i18n texts * feat: selectLanguage command * refactor: configuration keys * feat: selectLanguage command * feat: spanish translations for listeners, preconditions, categories, errors and roleAssignment messages * feat: spanish i18n for commands * fix: selectlanguages's ignore state * chore: version 2.4.0
- Loading branch information
1 parent
230d906
commit 2b4a120
Showing
109 changed files
with
1,801 additions
and
1,289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"singleQuote": true, | ||
"semi": false | ||
"semi": false, | ||
"printWidth": 120 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,35 @@ | ||
import { configuration } from '@/config' | ||
import { container, SapphireClient } from '@sapphire/framework' | ||
import { Cache, MongoDatabase } from '@/database' | ||
import { logger } from '@/utils' | ||
import '@sapphire/plugin-logger/register' | ||
|
||
const main = async () => { | ||
const client = new SapphireClient({ | ||
defaultPrefix: configuration.prefix, | ||
intents: ['GUILDS', 'GUILD_MEMBERS', 'GUILD_MESSAGES'], | ||
loadDefaultErrorListeners: false, | ||
}) | ||
|
||
logger.info(`Initializing application...`, { | ||
context: client.constructor.name, | ||
}) | ||
|
||
logger.info(`Trying to connect to mongo database...`, { | ||
context: client.constructor.name, | ||
}) | ||
try { | ||
container.db = await MongoDatabase.connect() | ||
container.cache = await Cache.init() | ||
} catch (error) { | ||
logger.error(`Database connection error. Could not connect to databases`, { | ||
context: client.constructor.name, | ||
}) | ||
} | ||
|
||
try { | ||
logger.info('Logging in...', { | ||
context: client.constructor.name, | ||
}) | ||
await client.login(configuration.token) | ||
} catch (error) { | ||
const { code, method, path } = error | ||
console.error(`Error ${code} trying to ${method} to ${path} path`) | ||
} | ||
} | ||
|
||
main().catch(() => | ||
logger.error('Bot initialization failed', { | ||
context: container.client.constructor.name, | ||
}) | ||
) | ||
import { configuration } from '@/config' | ||
import { container, SapphireClient } from '@sapphire/framework' | ||
import { Cache, MongoDatabase } from '@/database' | ||
import { i18nConfig, logger } from '@/utils' | ||
import '@sapphire/plugin-logger/register' | ||
import '@sapphire/plugin-i18next/register' | ||
|
||
const main = async () => { | ||
const client = new SapphireClient({ | ||
...configuration.client, | ||
intents: ['GUILDS', 'GUILD_MEMBERS', 'GUILD_MESSAGES'], | ||
i18n: i18nConfig, | ||
}) | ||
|
||
logger.info(`Initializing application...`, { | ||
context: client.constructor.name, | ||
}) | ||
|
||
logger.info(`Trying to connect to mongo database...`, { | ||
context: client.constructor.name, | ||
}) | ||
container.db = await MongoDatabase.connect() | ||
container.cache = await Cache.init() | ||
|
||
logger.info('Logging in...', { | ||
context: client.constructor.name, | ||
}) | ||
await client.login(configuration.client.token) | ||
} | ||
|
||
main().catch((reason) => { | ||
logger.error(`Bot initialization failed. Error: ${reason}`, { | ||
context: container.client.constructor.name, | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Command, CommandOptionsRunTypeEnum, container } from '@sapphire/framework' | ||
import type { Message } from 'discord.js' | ||
import { logger, CustomPrecondition, languageKeys, CustomCommand, CustomArgs } from '@/utils' | ||
|
||
/** | ||
* Replies the receives message on command. | ||
*/ | ||
export class CancelGameCommand extends CustomCommand { | ||
constructor(context: Command.Context, options: Command.Options) { | ||
super(context, { | ||
...options, | ||
aliases: ['cg'], | ||
description: languageKeys.commands.games.cancelgame.description, | ||
preconditions: [CustomPrecondition.BotInitializedOnly], | ||
runIn: [CommandOptionsRunTypeEnum.GuildAny], | ||
}) | ||
} | ||
|
||
/** | ||
* It executes when someone types the "say" command. | ||
*/ | ||
async messageRun(message: Message, { t }: CustomArgs): Promise<Message<boolean>> { | ||
const { id } = message.guild | ||
|
||
try { | ||
const guild = await container.db.guildService.getById(id) | ||
|
||
if (guild && !guild.gameInstanceActive) { | ||
return message.channel.send(t(languageKeys.commands.games.cancelgame.noActiveGame)) | ||
} | ||
|
||
guild.gameInstanceActive = false | ||
await guild.save() | ||
return message.channel.send(t(languageKeys.commands.games.cancelgame.gameCancelled)) | ||
} catch (error) { | ||
logger.error( | ||
`(${this.constructor.name}): MongoDB Connection error. Could not change game instance state for '${message.guild.name}' server` | ||
) | ||
} | ||
|
||
return message.channel.send(t(languageKeys.errors.unexpectedError)) | ||
} | ||
} |
Oops, something went wrong.