-
Notifications
You must be signed in to change notification settings - Fork 404
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
1 parent
444c4cb
commit db24f9d
Showing
1 changed file
with
31 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,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\`\`\``); | ||
}, | ||
}); |