-
Notifications
You must be signed in to change notification settings - Fork 331
/
Copy pathnotes.js
152 lines (141 loc) · 5.14 KB
/
notes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
const {
note,
smd,
prefix
} = require('../lib')
//---------------------------------------------------------------------------
smd({
cmdname: "delnote",
type: "notes",
filename: __filename,
fromMe:true,
info: "Deletes note from db.",
use: '< note id | 1 >',
},
async(message, match) => {
try{
let id = match.split(' ')[0];
if (!id || isNaN(id)) { return message.reply(`*Provide Note ID, Example: ${prefix}delnote 1*`); }
let res = await note.delnote(message,id)
return await message.reply(res.msg);
}catch(e){ await message.error(`${e}\n\ncommand: delnote`,e,) }
}
)
//---------------------------------------------------------------------------
smd({
cmdname: "delallnote",
type: "notes",
fromMe:true,
filename: __filename,
info: "Deletes all notes from db."
},
async(message) => {
try{
let res = await note.delallnote(message)
return await message.reply(res.msg);
}catch(e){ await message.error(`${e}\n\ncommand: delallnotes`,e,) }
}
)
//---------------------------------------------------------------------------
smd({
cmdname: "allnote",
type: "notes",
filename: __filename,
fromMe:true,
info: "Shows list of all notes."
},
async(message,) => {
try{
let res = await note.allnotes(message,"all")
return await message.reply(res.msg);
}catch(e){ await message.error(`${e}\n\ncommand: delallnotes`,e,`*Can't fetch data, Sorry!!*`) }
}
)
//---------------------------------------------------------------------------
smd({
cmdname: "getnote",
type: "notes",
filename: __filename,
fromMe:true,
info: "Shows note by id.",
use: '< id|1|2 >',
},
async(message,match) => {
try{
if(!match)return await message.reply(`*Provide Note ID, Ex: ${prefix}getnote id|1|2|..*`);
let res = await note.allnotes(message,match.split(" ")[0].toLowerCase().trim())
return await message.reply(res.msg);
}catch(e){ await message.error(`${e}\n\ncommand: getnote`,e,`*Can't fetch data, Sorry!!*`) }
}
)
//---------------------------------------------------------------------------
smd({
cmdname: "addnote",
type: "notes",
info: "Adds a note on db.",
fromMe:true,
filename: __filename,
use: '< text >',
},
async( message, match,) => {
try{
if (!match) return await message.reply(`*Please provide text to save in notes!*`)
let res = await note.addnote(message,match)
return await message.reply(res.msg);
}catch(e){ await message.error(`${e}\n\ncommand: addnote`,e,) }
}
)
//---------------------------------------------------------------------------
// ADD NOTE COMMANDS
//---------------------------------------------------------------------------
smd({
cmdname: "note",
type: "notes",
fromMe:true,
filename: __filename,
info: "Shows list of all notes."
},
async(message, text,{smd}) => {
try{
let txt = `╭───── *『 MONGODB NOTES 』* ───◆
┃ Here You Can Store Notes For Later Use
┃ *------------------------------------------*
┃ ┌┤ *✯---- ADD NEW NOTE ----⦿*
┃ │✭ *Cmd :* ${prefix+smd} add 'Your Text'
┃ │✭ *Usage :* Save Text in MongoDb Server
┃ ╰───────────────────◆
┃
┃ ┌┤ *✯---- GET ALL NOTES ----⦿*
┃ │✭ *Cmd :* ${prefix+smd} all
┃ │✭ *Usage :* Read/Get All Saved Notes
┃ ╰───────────────────◆
┃
┃ ┌┤ *✯---- DELETE A NOTE ----⦿*
┃ │✭ *Cmd :* ${prefix+smd} del 'note id'
┃ │✭ *Usage :* Delete A Single Note By ID Number
┃ ╰───────────────────◆
┃
┃ ┌┤ *✯---- DELETE ALL NOTES ----⦿*
┃ │✭ *Cmd :* ${prefix+smd} delall
┃ │✭ *Usage :* Delete All Saved Notes
┃ ╰───────────────────◆
╰━━━━━━━━━━━━━━━━━━━━━━──⊷` ;
if (!text) return await message.reply(txt);
let action = text.split(' ')[0].trim().toLowerCase()
if(action === "add" || action === "new" ){
let res = await note.addnote(message,text.replace("add", "").replace("new", ""))
return await message.reply(res.msg);
}else if(action === "all"){
let res = await note.allnotes(message,"all")
return await message.reply(res.msg);
}else if(action === "delall"){
let res = await note.delallnote(message)
return await message.reply(res.msg);
}else if(action === "del"){
let id = text.split(' ')[1];
if (!id || isNaN(id)) { return message.reply("*Uhh Please, Provide Note ID. Example: .delnote 1*"); }
let res = await note.delnote(message,id)
return await message.reply(res.msg);
}else { return await message.reply(`*Invalid action provided, please follow* \n\n${txt}`) ; }
}catch(e){ await message.error(`${e}\n\ncommand: addnote`,e,`*Can't fetch data, Sorry!*`) }
})