Skip to content

Commit

Permalink
add pet admin command
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherBThai committed Jul 12, 2023
1 parent 444c4cb commit db24f9d
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/commands/commandList/admin/addPet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* OwO Bot for Discord
* Copyright (C) 2023 Christopher Thai
* This software is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
* For more information, see README.md and LICENSE
*/

const CommandInterface = require('../../CommandInterface.js');

module.exports = new CommandInterface({
alias: ['addpet'],

owner: true,

execute: async function () {
const name = this.args[0];
const id = this.args[1];

const animal = this.global.validAnimal(name);
if (!animal) {
return this.errorMsg(', Unknown animal');
}
if (!this.global.isInt(id)) {
return this.errorMsg(', Invalid user id');
}

const sql = `INSERT INTO animal (id, name, count, totalcount) VALUES (?, ?, 1, 1);`;
const result = await this.query(sql, [id, animal.value]);
this.send(`\`\`\`\n${JSON.stringify(result, null, 2)}\n\`\`\``);
},
});

0 comments on commit db24f9d

Please sign in to comment.