Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sanae
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Levatax
Sanae
Commits
4e9d13e4
Commit
4e9d13e4
authored
Sep 22, 2020
by
Levatax
Browse files
Options
Downloads
Patches
Plain Diff
Add new file
parent
f83ceb93
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
bot.js
+55
-0
55 additions, 0 deletions
bot.js
with
55 additions
and
0 deletions
bot.js
0 → 100644
+
55
−
0
View file @
4e9d13e4
const
discord
=
require
(
'
discord.js
'
);
const
bot
=
new
discord
.
Client
();
const
ready
=
require
(
'
./events/ready
'
);
const
message
=
require
(
'
./events/message
'
);
const
fs
=
require
(
'
fs
'
);
const
settings
=
require
(
'
./settings.json
'
);
bot
.
commands
=
new
discord
.
Collection
();
bot
.
aliases
=
new
discord
.
Collection
();
ready
.
ready
(
bot
);
message
.
message
(
bot
,
settings
,
discord
);
fs
.
readdir
(
"
./commands/
"
,
(
err
,
files
)
=>
{
if
(
err
)
console
.
error
(
err
);
let
jsfiles
=
files
.
filter
(
f
=>
f
.
split
(
"
.
"
).
pop
()
===
"
js
"
);
if
(
jsfiles
.
length
<=
0
)
return
console
.
log
(
"
There are no commands to load...
"
);
console
.
log
(
`Loading
${
jsfiles
.
length
}
commands...`
);
jsfiles
.
forEach
((
f
,
i
)
=>
{
let
props
=
require
(
`./commands/
${
f
}
`
);
console
.
log
(
`
${
i
+
1
}
:
${
f
}
loaded!`
);
bot
.
commands
.
set
(
props
.
help
.
name
,
props
);
props
.
help
.
aliases
.
forEach
(
alias
=>
{
bot
.
aliases
.
set
(
alias
,
props
.
help
.
name
);
});
});
});
bot
.
loadCommand
=
(
commandName
)
=>
{
try
{
let
props
=
require
(
`../commands/
${
commandName
}
`
);
if
(
props
.
init
)
props
.
init
(
bot
);
bot
.
commands
.
set
(
commandName
,
props
);
props
.
help
.
aliases
.
forEach
(
alias
=>
{
bot
.
aliases
.
set
(
alias
,
props
.
help
.
name
);
});
return
false
;
}
catch
(
err
)
{
return
[
console
.
error
(
err
)];
}
};
bot
.
unloadCommand
=
async
(
commandName
)
=>
{
try
{
if
(
!
commandName
)
return
`
\`
${
commandName
}
\`
I Can't Find This Command!`
;
if
(
commandName
.
shutdown
)
await
commandName
.
shutdown
(
bot
);
delete
require
.
cache
[
require
.
resolve
(
`../commands/
${
commandName
}
.js`
)];
return
false
;
}
catch
(
err
)
{
return
[
console
.
error
(
err
)];
}
};
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment