-
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.
- Loading branch information
Showing
10 changed files
with
320 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Command, CommandOptions } from 'axoncore'; | ||
|
||
class Add extends Command { | ||
constructor(module) { | ||
super(module); | ||
|
||
this.label = 'add'; | ||
this.aliases = ['add']; | ||
|
||
this.hasSubcmd = false; | ||
|
||
this.info = { | ||
owners: ['KhaaZ'], | ||
name: 'add', | ||
description: 'Indique que tu as le PNJ en question sur ton ile.', | ||
usage: 'add [pnj<blaise, celeste, racine, rounard, sarah>]', | ||
examples: [ | ||
'add celeste', | ||
'add rounard', | ||
'add sarah', | ||
], | ||
}; | ||
|
||
this.options = new CommandOptions(this, { | ||
argsMin: 1, | ||
} ); | ||
} | ||
|
||
async execute( { msg, args } ) { | ||
const pnj = this.module.PNJs.find(e => e.toLowerCase() === args[0].toLowerCase() ); | ||
if (!pnj) { | ||
return this.sendError(msg.channel, 'Donnez un PNJ valide !'); | ||
} | ||
|
||
this.module.pnjDB.add(pnj.toLowerCase(), msg.author.id); | ||
|
||
return this.sendMessage(msg.channel, `:white_check_mark: ${pnj} se trouve actuellement sur ton île, c'est noté !`); | ||
} | ||
} | ||
|
||
export default Add; |
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,30 @@ | ||
import { Command, CommandOptions } from 'axoncore'; | ||
|
||
class Blaise extends Command { | ||
constructor(module) { | ||
super(module); | ||
|
||
this.label = 'blaise'; | ||
this.aliases = ['blaise']; | ||
|
||
this.hasSubcmd = false; | ||
|
||
this.info = { | ||
owners: ['KhaaZ'], | ||
name: 'blaise', | ||
description: 'Affiche une liste de personne ayant le PNJ demandé sur leur ile.', | ||
usage: 'blaise [page]', | ||
examples: ['blaise', 'blaise 1'], | ||
}; | ||
|
||
this.options = new CommandOptions(this, { | ||
argsMin: 0, | ||
} ); | ||
} | ||
|
||
async execute( { msg, args } ) { | ||
return this.module.pnj(msg, args[0], 'Blaise'); | ||
} | ||
} | ||
|
||
export default Blaise; |
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,30 @@ | ||
import { Command, CommandOptions } from 'axoncore'; | ||
|
||
class Celeste extends Command { | ||
constructor(module) { | ||
super(module); | ||
|
||
this.label = 'celeste'; | ||
this.aliases = ['celeste']; | ||
|
||
this.hasSubcmd = false; | ||
|
||
this.info = { | ||
owners: ['KhaaZ'], | ||
name: 'celeste', | ||
description: 'Affiche une liste de personne ayant le PNJ demandé sur leur ile.', | ||
usage: 'celeste [page]', | ||
examples: ['celeste', 'celeste 1'], | ||
}; | ||
|
||
this.options = new CommandOptions(this, { | ||
argsMin: 0, | ||
} ); | ||
} | ||
|
||
async execute( { msg, args } ) { | ||
return this.module.pnj(msg, args[0], 'Celeste'); | ||
} | ||
} | ||
|
||
export default Celeste; |
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,41 @@ | ||
import { Command, CommandOptions } from 'axoncore'; | ||
|
||
class Delete extends Command { | ||
constructor(module) { | ||
super(module); | ||
|
||
this.label = 'delete'; | ||
this.aliases = ['delete']; | ||
|
||
this.hasSubcmd = false; | ||
|
||
this.info = { | ||
owners: ['KhaaZ'], | ||
name: 'delete', | ||
description: 'Indique que le PNJ en question n\'est plus sur ton ile.', | ||
usage: 'delete [pnj<blaise, celeste, racine, rounard, sarah>]', | ||
examples: [ | ||
'delete celeste', | ||
'delete rounard', | ||
'delete sarah', | ||
], | ||
}; | ||
|
||
this.options = new CommandOptions(this, { | ||
argsMin: 1, | ||
} ); | ||
} | ||
|
||
async execute( { msg, args } ) { | ||
const pnj = this.module.PNJs.find(e => e.toLowerCase() === args[0].toLowerCase() ); | ||
if (!pnj) { | ||
return this.sendError(msg.channel, 'Donnez un PNJ valide !'); | ||
} | ||
|
||
this.module.pnjDB.delete(pnj.toLowerCase(), msg.author.id); | ||
|
||
return this.sendMessage(msg.channel, `:x: ${pnj} n'est plus sur ton île, c'est noté !`); | ||
} | ||
} | ||
|
||
export default Delete; |
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,30 @@ | ||
import { Command, CommandOptions } from 'axoncore'; | ||
|
||
class Racine extends Command { | ||
constructor(module) { | ||
super(module); | ||
|
||
this.label = 'racine'; | ||
this.aliases = ['racine']; | ||
|
||
this.hasSubcmd = false; | ||
|
||
this.info = { | ||
owners: ['KhaaZ'], | ||
name: 'racine', | ||
description: 'Affiche une liste de personne ayant le PNJ demandé sur leur ile.', | ||
usage: 'racine [page]', | ||
examples: ['racine', 'racine 1'], | ||
}; | ||
|
||
this.options = new CommandOptions(this, { | ||
argsMin: 0, | ||
} ); | ||
} | ||
|
||
async execute( { msg, args } ) { | ||
return this.module.pnj(msg, args[0], 'Racine'); | ||
} | ||
} | ||
|
||
export default Racine; |
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,30 @@ | ||
import { Command, CommandOptions } from 'axoncore'; | ||
|
||
class Rounard extends Command { | ||
constructor(module) { | ||
super(module); | ||
|
||
this.label = 'rounard'; | ||
this.aliases = ['rounard']; | ||
|
||
this.hasSubcmd = false; | ||
|
||
this.info = { | ||
owners: ['KhaaZ'], | ||
name: 'rounard', | ||
description: 'Affiche une liste de personne ayant le PNJ demandé sur leur ile.', | ||
usage: 'rounard [page]', | ||
examples: ['rounard', 'rounard 1'], | ||
}; | ||
|
||
this.options = new CommandOptions(this, { | ||
argsMin: 0, | ||
} ); | ||
} | ||
|
||
async execute( { msg, args } ) { | ||
return this.module.pnj(msg, args[0], 'Rounard'); | ||
} | ||
} | ||
|
||
export default Rounard; |
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,30 @@ | ||
import { Command, CommandOptions } from 'axoncore'; | ||
|
||
class Sarah extends Command { | ||
constructor(module) { | ||
super(module); | ||
|
||
this.label = 'sarah'; | ||
this.aliases = ['sarah']; | ||
|
||
this.hasSubcmd = false; | ||
|
||
this.info = { | ||
owners: ['KhaaZ'], | ||
name: 'sarah', | ||
description: 'Affiche une liste de personne ayant le PNJ demandé sur leur ile.', | ||
usage: 'sarah [page]', | ||
examples: ['sarah', 'sarah 1'], | ||
}; | ||
|
||
this.options = new CommandOptions(this, { | ||
argsMin: 0, | ||
} ); | ||
} | ||
|
||
async execute( { msg, args } ) { | ||
return this.module.pnj(msg, args[0], 'Sarah'); | ||
} | ||
} | ||
|
||
export default Sarah; |
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,7 @@ | ||
export { default as Add } from './Add'; | ||
export { default as Delete } from './Delete'; | ||
export { default as Blaise } from './Blaise'; | ||
export { default as Celeste } from './Celeste'; | ||
export { default as Racine } from './Racine'; | ||
export { default as Rounard } from './Rounard'; | ||
export { default as Sarah } from './Sarah'; |
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,80 @@ | ||
import { Module } from 'axoncore'; | ||
|
||
import * as commands from './commands/index'; | ||
import PNJDB from '../../lib/PNJDB'; | ||
|
||
class PNJ extends Module { | ||
constructor(...args) { | ||
super(...args); | ||
|
||
this.label = 'Pnj'; | ||
|
||
this.enabled = true; | ||
this.serverBypass = true; | ||
|
||
this.info = { | ||
name: 'pnj', | ||
description: 'The PNJ module (check pnj status).', | ||
}; | ||
|
||
this.pnjDB = new PNJDB(this.axon.custom.DBLocation); | ||
|
||
this.PNJs = [ | ||
'Blaise', | ||
'Celeste', | ||
'Racine', | ||
'Rounard', | ||
'Sarah', | ||
]; | ||
} | ||
|
||
init() { | ||
return { commands }; | ||
} | ||
|
||
pnj(msg, page, pnj) { | ||
const chunk = this.calculateChunk(page || 1); | ||
|
||
const users = this.pnjDB.getAll(pnj.toLowerCase() ); | ||
if (users.length < chunk) { | ||
return this.sendError(msg.channel, 'Page invalide !', { triggerCooldown: false } ); | ||
} | ||
|
||
const date = new Date(); | ||
|
||
const all = users.map(u => { | ||
const user = msg.channel.guild.members.get(u.id); | ||
if (!user) { | ||
this.module.navetDB.delete(u.id); | ||
} | ||
return user.username; | ||
} ); | ||
|
||
const display = this.chunk(all, chunk) | ||
.map( (u, i) => `${chunk + i + 1}) [${u}]`); | ||
|
||
if (display.length < 1) { | ||
return this.sendError(msg.channel, `Personne n'a enregistré avoir ${pnj} sur son ile pour le moment.`); | ||
} | ||
|
||
return this.sendMessage(msg.channel, { | ||
embed: { | ||
timestamp: date, | ||
title: 'Céleste', | ||
description: `*Liste des joueurs ayant ${pnj} sur leur île !*\n\n${display.join('\n')}`, | ||
color: 5301186, | ||
}, | ||
} ); | ||
} | ||
|
||
calculateChunk(i) { | ||
return (i - 1) * 10; | ||
} | ||
|
||
chunk(arr, start) { | ||
const end = start + 10; | ||
return arr.slice(start, end); | ||
} | ||
} | ||
|
||
export default PNJ; |
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