Skip to content

Commit

Permalink
Fix !knowme and !mm (#4)
Browse files Browse the repository at this point in the history
* ✨ Unfinished changes

* 🔥 Remove console log

* 🔥 Remove unnecessary console.logs

* 🔥 Remove another console.log

* 🔥 Remove unecessary comment

* Add top level documentation and fix missing import (#2)

* 🐛 Fix missing import

* 📝 Add top level documentation

* 📝 Fix typo

* 🐛 Fix !knowme and !mm

* v1.0.1
  • Loading branch information
tiffafoo authored Apr 30, 2018
1 parent 9f0409a commit a9081c6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "camperbot",
"version": "1.0.0",
"version": "1.0.1",
"description": "freeCodeCamp montreal discord bot",
"main": "src/app.js",
"repository": "[email protected]:sirMerr/camperbot.git",
Expand Down
20 changes: 10 additions & 10 deletions src/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const knowme = msg => {

insertAccount({
discordId: msg.author.id,
createdAt: msg.member.joinedAt,
callback,
errorHandler,
});
Expand All @@ -48,22 +49,21 @@ export const repopulate = msg => {

// Give user(s) marshmellows
export const marshmellow = msg => {
const usersIds = msg.mentions.users.keyArray();
const mentionedId = msg.mentions.users.first().id;

const callback = data => {};

if (usersIds.length > 0) {
if (mentionedId === msg.author.id) {
msg.reply("lol you can't give yourself marshmellows");
} else {
incrementMarshmellow({
discordIds: usersIds,
callback,
discordId: mentionedId,
callback: () => {
console.log('!mm success');
},
errorHandler: err => {
console.log('!mm', err);
msg.reply('Unable to give marshmellows :(');
},
});
} else {
msg.reply(
"you didn't say which user(s) you wanted to give a marshmellow to!"
);
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ export const insertAccount = ({

// Increment marshmellows for a given array of users
export const incrementMarshmellow = ({
discordIds, // array of discord ids
discordId, // array of discord ids
callback,
errorHandler,
}) => {
const query = sql`
UPDATE accounts SET marshmellows = marshmellows + 1
WHERE discord_id IN (${"'" + discordIds.join() + "'"})
WHERE discord_id = ${discordId}
RETURNING accounts.marshmellows
`;

Expand Down

0 comments on commit a9081c6

Please sign in to comment.