Skip to content

Commit

Permalink
メモの削除コマンドの追加 (#11)
Browse files Browse the repository at this point in the history
* メモの削除機能の追加

* 削除して作り直した

npm i ができなかったから
  • Loading branch information
mouse484 authored and yhay81 committed Jan 5, 2019
1 parent bf9d1e9 commit cd02d04
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 987 deletions.
45 changes: 45 additions & 0 deletions files/commands/rm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
module.exports.set = {
name: "rm", //名前
aliases: ["rm"], //エイリアス
};

//コマンド内容
module.exports.run = async (db, client, message) => {
const responseMessage = await message.channel.send("メモを削除できるか確認しています...");

const memo = message.content.split(" ");
const memo_title = memo[1];
if (memo.length < 2) {
responseMessage.edit("正しく入力してください。\n正しくは`!mrm [タイトル]`です。");
return;
}
db.get("SELECT * FROM memo WHERE user_id=? AND title=?;",
[message.author.id, memo_title],
(err, row) => {
if (err) return;
if (!row) {
responseMessage.edit(`${memo_title}というタイトルのメモは存在しません`);
return;
}
db.get("DELETE FROM memo WHERE user_id=? AND title=?",
[message.author.id, memo_title],
(err, row) => {
if (err) return;

const embed = {
title: "メモを削除しました",
color: 0xD0021B,
fields: [
{ name: "タイトル", value: memo_title },
],
footer: {
icon_url: message.author.avatarURL,
text: message.author.tag,
},
};
responseMessage.edit({ embed });

})
});

};
Loading

0 comments on commit cd02d04

Please sign in to comment.