Skip to content

Commit

Permalink
feat: locale stats (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustDams authored Mar 30, 2023
1 parent edd019c commit 9a592ca
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 12 deletions.
5 changes: 3 additions & 2 deletions database/commandsStats.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const CommandsStats = require('./models/commandsStatsModel')

const create = (commandName, commandType, date) => {
const create = (commandName, commandType, { createdAt, locale }) => {
const newCommandStats = new CommandsStats({
commandName: commandName,
commandType: commandType,
date: date
locale: locale,
date: createdAt
})

newCommandStats.save()
Expand Down
1 change: 1 addition & 0 deletions database/models/commandsStatsModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const mongoose = require('mongoose')
const commandsStatsSchema = mongoose.Schema({
commandName: String,
commandType: String,
locale: String,
date: Date,
})

Expand Down
6 changes: 3 additions & 3 deletions events/interactionCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module.exports = {
interaction
.deferUpdate()
.then(() => {
CommandsStats.create(interaction.customId, 'selectmenu', interaction.createdAt)
CommandsStats.create(interaction.customId, 'selectmenu', interaction)
interaction.client.selectmenus?.get(interaction.customId)?.execute(interaction)
.then(e => editInteraction(interaction, e))
.catch(err => errorInteraction(interaction, err, getTranslation('error.execution.selectmenu', interaction.locale)))
Expand All @@ -76,7 +76,7 @@ module.exports = {
interaction
.deferReply()
.then(() => {
CommandsStats.create(interaction.commandName, 'contextmenu', interaction.createdAt)
CommandsStats.create(interaction.commandName, 'contextmenu', interaction)
interaction.client.contextmenus.get(interaction.commandName)?.execute(interaction)
.then(resp => interaction
.followUp(resp)
Expand All @@ -91,7 +91,7 @@ module.exports = {
interaction
.deferReply()
.then(() => {
CommandsStats.create(interaction.commandName, 'command', interaction.createdAt)
CommandsStats.create(interaction.commandName, 'command', interaction)
interaction.client.commands.get(interaction.commandName)?.execute(interaction)
.then(resp => {
if (Array.isArray(resp))
Expand Down
2 changes: 1 addition & 1 deletion interactions/buttons/fUSG.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = {

if (interaction.user.id !== value.u) return

CommandsStats.create('find', 'button - player', interaction.createdAt)
CommandsStats.create('find', 'button - player', interaction)

const players = interaction.message.components.at(3)?.components.map(p => JSON.parse(p.customId).s) || []
const excludedPlayers = interaction.message.components.at(4)?.components.map(p => p.customId) || []
Expand Down
2 changes: 1 addition & 1 deletion interactions/buttons/pageDS.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
if (interaction.user.id !== json.u) return

const commandName = interaction.message.interaction.commandName
CommandsStats.create(commandName, `button - ${getTypePage(json)}`, interaction.createdAt)
CommandsStats.create(commandName, `button - ${getTypePage(json)}`, interaction)

loadingCard(interaction)

Expand Down
2 changes: 1 addition & 1 deletion interactions/buttons/pageLast.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {

const players = interaction.message.components.at(3)?.components.map(p => JSON.parse(p.customId).s) || []
const excludedPlayers = interaction.message.components.at(4)?.components.map(p => p.customId) || []
CommandsStats.create('last', `button - ${getTypePage(json)}`, interaction.createdAt)
CommandsStats.create('last', `button - ${getTypePage(json)}`, interaction)

loadingCard(interaction)

Expand Down
2 changes: 1 addition & 1 deletion interactions/buttons/uCSG.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = {

if (interaction.user.id !== json.u) return

CommandsStats.create('compare', `button - ${getTypeGraph(json)}`, interaction.createdAt)
CommandsStats.create('compare', `button - ${getTypeGraph(json)}`, interaction)

loadingCard(interaction)

Expand Down
2 changes: 1 addition & 1 deletion interactions/buttons/uDSG.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = {
if (interaction.user.id !== json.u) return

const commandName = interaction.message.interaction.commandName
CommandsStats.create(commandName, `button - ${getTypeGraph(json)}`, interaction.createdAt)
CommandsStats.create(commandName, `button - ${getTypeGraph(json)}`, interaction)

loadingCard(interaction)

Expand Down
2 changes: 1 addition & 1 deletion interactions/buttons/uLSG.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = {

if (interaction.user.id !== json.u) return

CommandsStats.create('laststats', `button - ${getTypeGraph(json)}`, interaction.createdAt)
CommandsStats.create('laststats', `button - ${getTypeGraph(json)}`, interaction)

loadingCard(interaction)

Expand Down
2 changes: 1 addition & 1 deletion interactions/buttons/uSG.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = {
async execute(interaction, json) {
if (interaction.user.id !== json.u) return

CommandsStats.create('stats', `button - ${getTypeGraph(json)}`, interaction.createdAt)
CommandsStats.create('stats', `button - ${getTypeGraph(json)}`, interaction)

loadingCard(interaction)

Expand Down

0 comments on commit 9a592ca

Please sign in to comment.