Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
74 Legacy V3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
insert
74 Legacy V3
Commits
af589602
Commit
af589602
authored
Jul 07, 2018
by
insert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added database + notes system as example.
parent
005e0606
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
550 additions
and
2 deletions
+550
-2
.gitignore
.gitignore
+2
-1
core/system/note.js
core/system/note.js
+17
-0
database/index.js
database/index.js
+30
-0
index.js
index.js
+2
-1
package-lock.json
package-lock.json
+497
-0
package.json
package.json
+2
-0
No files found.
.gitignore
View file @
af589602
token.json
node_modules
\ No newline at end of file
node_modules
database/data/
\ No newline at end of file
core/system/note.js
0 → 100644
View file @
af589602
const
db
=
needs
(
'
database
'
);
module
.
exports
=
(
msg
,
args
)
=>
{
if
(
args
.
length
<
1
)
{
db
.
get
(
msg
.
author
.
id
,
"
note
"
).
then
(
note
=>
{
msg
.
channel
.
send
(
"
```
\n
"
+
note
+
"
\n
```
"
);
}).
catch
(
e
=>
{
msg
.
reply
(
"
You don't have any note! Do `;note <note>` to set it.
"
);
});
return
;
}
db
.
put
(
msg
.
author
.
id
,
"
note
"
,
args
.
join
(
'
'
)).
then
(()
=>
{
msg
.
reply
(
"
Successfully set your note!
"
);
}).
catch
(
e
=>
{
msg
.
reply
(
"
Oops! An error occurred!
"
+
e
);
});
};
\ No newline at end of file
database/index.js
0 → 100644
View file @
af589602
const
fs
=
require
(
'
fs
'
);
const
path
=
require
(
'
path
'
);
const
levelup
=
require
(
'
levelup
'
);
const
leveldown
=
require
(
'
leveldown
'
);
if
(
!
fs
.
existsSync
(
'
./database/data
'
))
fs
.
mkdirSync
(
'
./database/data
'
);
module
.
exports
=
{
put
:
(
id
,
key
,
value
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
let
db
=
levelup
(
leveldown
(
path
.
resolve
(
'
./database/data/
'
+
id
)))
db
.
put
(
key
,
value
).
then
(
resolve
).
catch
(
reject
);
db
.
close
();
});
},
get
:
(
id
,
key
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
let
db
=
levelup
(
leveldown
(
path
.
resolve
(
'
./database/data/
'
+
id
)))
db
.
get
(
key
).
then
(
resolve
).
catch
(
reject
);
db
.
close
();
});
},
del
:
(
id
,
key
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
let
db
=
levelup
(
leveldown
(
path
.
resolve
(
'
./database/data/
'
+
id
)))
db
.
del
(
key
).
then
(
resolve
).
catch
(
reject
);
db
.
close
();
});
}
};
\ No newline at end of file
index.js
View file @
af589602
const
discord
=
require
(
'
discord.js
'
);
const
chalk
=
require
(
'
chalk
'
);
const
client
=
new
discord
.
Client
();
const
database
=
require
(
'
./database
'
);
const
services
=
require
(
'
./services
'
);
const
libs
=
require
(
'
./libs
'
);
const
fs
=
require
(
'
fs
'
);
...
...
@@ -18,7 +19,7 @@ console.log(chalk`
`
.
replace
(
/#/g
,
chalk
.
bgMagenta
(
'
'
)));
global
.
components
=
{
discord
,
client
,
services
,
libs
};
global
.
components
=
{
discord
,
client
,
database
,
services
,
libs
};
global
.
needs
=
(
component
)
=>
{
if
(
Object
.
keys
(
components
).
indexOf
(
component
)
<
0
)
throw
new
Error
(
'
Not a valid component!
'
);
return
components
[
component
];
...
...
package-lock.json
View file @
af589602
This diff is collapsed.
Click to expand it.
package.json
View file @
af589602
...
...
@@ -20,6 +20,8 @@
"dependencies"
:
{
"
chalk
"
:
"
^2.4.1
"
,
"
discord.js
"
:
"
^11.3.2
"
,
"
leveldown
"
:
"
^4.0.1
"
,
"
levelup
"
:
"
^3.1.0
"
,
"
node-opus
"
:
"
^0.3.0
"
,
"
request
"
:
"
^2.87.0
"
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment