Skip to content
Snippets Groups Projects
Unverified Commit c8c02feb authored by Maxime FRIESS's avatar Maxime FRIESS :blue_heart:
Browse files

[version] 1.4.1

parents 5812ce66 181abf0d
Branches
No related merge requests found
{
"name": "seb-bot",
"version": "1.4.0",
"version": "1.4.1",
"main": "index.js",
"repository": "https://git.unistra.fr/amicale-core/seb-bot",
"author": "Maxime Friess <M4x1me@pm.me>",
......
......@@ -87,8 +87,8 @@ class SebAPI {
return await this.__request("GET", "/api/products_categories");
}
async create_member(firstname, lastname, discord_id) {
return await this.__request("POST", "/api/members", { firstname: firstname, lastname: lastname, discord_id: discord_id });
async create_person(firstname, lastname, discord_id) {
return await this.__request("POST", "/api/people", { firstname: firstname, lastname: lastname, discord_id: discord_id });
}
async stats() {
......
......@@ -21,21 +21,21 @@ import { ApplicationCommandOptionType } from 'discord-api-types/v9';
import SebApi from '../api/SebApi.js';
import Command from '../Command.js';
class CotiserCommand extends Command {
class RegisterCommand extends Command {
constructor() {
super();
}
getName() {
return "cotiser";
return "register";
}
getDescription() {
return "S'inscrire pour cotiser à l'amicale.";
return "S'inscrire dans Seb, pour cotiser à l'amicale.";
}
getConfigs() {
return ["command.ping.message"];
return [];
}
getOptions() {
......@@ -54,22 +54,23 @@ class CotiserCommand extends Command {
async execute(interaction) {
let firstname = interaction.options.getString('prénom');
let lastname = interaction.options.getString('nom');
firstname = firstname.charAt(0).toUpperCase() + firstname.slice(1).toLowerCase();
let lastname = interaction.options.getString('nom').toUpperCase();
let {good, error, status, data} = await SebApi.create_member(firstname, lastname, interaction.user.id);
let {good, error, status, data} = await SebApi.create_person(firstname, lastname, interaction.user.id);
if (good) {
let message = "";
message += `Bienvenue à l'amicale ${data.data.firstname}!\n`;
message += `Afin d'être considéré comme membre à part entière de l'association, il ne te reste plus qu'à payer la cotisation (${data.contribution} €) auprès d'un membre du bureau de l'amicale.`;
message += `Bienvenue dans Seb, ${data.data.firstname}!\n`;
message += `Si tu veux devenir membre de l'association, il ne te reste plus qu'à payer la cotisation au bureau de l'amicale.`;
interaction.editReply({ content: message, ephemeral: true });
} else if (status == 422) {
interaction.editReply({ content: "Ce compte discord est déjà enregistré en tant que membre dans Seb. Merci de contacter l'amicale en cas de problème.", ephemeral: true });
interaction.editReply({ content: "Ce compte discord est déjà enregistré dans Seb. Merci de contacter l'amicale en cas de problème.", ephemeral: true });
} else {
interraction.editReply({ content: "Erreur de connexion à Seb.", ephemeral: true });
}
}
}
export default CotiserCommand;
export default RegisterCommand;
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment