Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Byakuren
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
Reviath
Byakuren
Commits
50335208
Commit
50335208
authored
Apr 17, 2021
by
Reviath
Browse files
Options
Downloads
Patches
Plain Diff
Getting errors from json file and added ban command
parent
cdcbebbb
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
commands/ban.js
+40
-0
40 additions, 0 deletions
commands/ban.js
commands/eval.js
+5
-6
5 additions, 6 deletions
commands/eval.js
errors.json
+7
-0
7 additions, 0 deletions
errors.json
with
52 additions
and
6 deletions
commands/ban.js
0 → 100644
+
40
−
0
View file @
50335208
const
errors
=
require
(
'
../errors.json
'
);
exports
.
run
=
async
(
client
,
message
,
args
,
connection
)
=>
{
if
(
!
message
.
member
.
hasPermission
(
'
BAN_MEMBERS
'
))
{
message
.
channel
.
send
(
errors
.
insufficient_permission_for_user
);
return
;
};
const
user
=
message
.
mentions
.
users
.
first
()
||
message
.
guild
.
members
.
cache
.
get
(
args
[
0
]);
if
(
!
user
)
{
message
.
channel
.
send
(
errors
.
insufficient_args
)
return
;
};
let
reason
=
args
.
slice
(
1
).
join
(
'
'
);
if
(
reason
==
null
)
{
reason
=
"
Unspecified.
"
};
if
(
message
.
guild
.
member
(
user
).
roles
.
highest
.
position
>=
message
.
member
.
roles
.
highest
.
position
)
{
message
.
channel
.
send
(
errors
.
equal_or_more_permission
);
return
;
};
if
(
!
message
.
guild
.
member
(
user
).
bannable
)
{
message
.
channel
.
send
(
errors
.
insufficient_permission_for_bot
);
return
;
};
await
message
.
guild
.
member
(
user
).
ban
({
reason
:
reason
}).
catch
(
e
=>
{
message
.
channel
.
send
(
errors
.
unknown_error
);
return
;
});
message
.
channel
.
send
(
'
Successfully performed ban on specified user.
'
);
};
module
.
exports
.
help
=
{
name
:
'
ban
'
,
aliases
:
[]
};
\ No newline at end of file
This diff is collapsed.
Click to expand it.
commands/eval.js
+
5
−
6
View file @
50335208
const
config
=
require
(
'
../config.json
'
);
const
errors
=
require
(
'
../errors.json
'
);
exports
.
run
=
async
(
client
,
message
,
args
,
connection
)
=>
{
if
(
!
config
.
owner
.
includes
(
message
.
author
.
id
)){
message
.
channel
.
send
(
'
You don
\'
t own this bot.
'
)
message
.
channel
.
send
(
'
You don
\'
t own this bot.
'
)
;
return
;
}
};
try
{
const
code
=
args
.
join
(
'
'
);
if
(
!
code
)
{
message
.
channel
.
send
(
'
You need to send what you want to run.
'
);
message
.
channel
.
send
(
errors
.
insufficient_args
);
return
;
};
const
res
=
eval
(
code
);
...
...
@@ -19,7 +18,7 @@ exports.run = async (client, message, args, connection) => {
}
catch
(
err
)
{
message
.
channel
.
send
(
`
\`
Error:
\`
\`\`\`
xl\n
${
err
}
\n
\`\`\`
`
);
};
}
}
;
module
.
exports
.
help
=
{
name
:
'
eval
'
,
aliases
:
[]
...
...
This diff is collapsed.
Click to expand it.
errors.json
0 → 100644
+
7
−
0
View file @
50335208
{
"insufficient_permission_for_user"
:
"You don't have enough permission to run this command."
,
"equal_or_more_permission"
:
"You can't take action on members with equal or higher position."
,
"insufficient_permission_for_bot"
:
"I don't have enough permission."
,
"unknown_error"
:
"An error occurred while executing this command."
,
"insufficient_args"
:
"You must specify all required args"
}
\ 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