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
058a9c73
Commit
058a9c73
authored
Apr 17, 2021
by
Reviath
Browse files
Options
Downloads
Patches
Plain Diff
Added welcome-channel command.
parent
c86e4083
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
commands/welcome-channel.js
+78
-0
78 additions, 0 deletions
commands/welcome-channel.js
errors.json
+2
-1
2 additions, 1 deletion
errors.json
with
80 additions
and
1 deletion
commands/welcome-channel.js
0 → 100644
+
78
−
0
View file @
058a9c73
const
errors
=
require
(
'
../errors.json
'
);
const
config
=
require
(
'
../config.json
'
);
exports
.
run
=
async
(
client
,
message
,
args
,
connection
)
=>
{
if
(
!
message
.
member
.
hasPermission
(
'
ADMINISTRATOR
'
))
{
message
.
channel
.
send
(
errors
.
insufficient_permission_for_user
).
catch
(
e
=>
{
return
;
});
};
if
(
!
args
[
0
])
{
message
.
channel
.
send
(
`
${
errors
.
insufficient_args
}
`
).
catch
(
e
=>
{
return
;
});
return
;
};
let
channel
;
await
connection
.
query
(
`SELECT channel FROM welcome_channel WHERE guild ='
${
message
.
guild
.
id
}
'`
,
function
(
err
,
result
)
{
if
(
err
)
{
throw
err
;
};
if
(
result
.
length
>
0
)
{
channel
=
result
[
0
].
channel
;
}
else
{
channel
=
"
none
"
;
};
});
if
(
args
[
0
]
==
"
reset
"
)
{
if
(
channel
==
"
none
"
){
message
.
channel
.
send
(
errors
.
not_existing_on_db
).
catch
(
e
=>
{
return
;
});
return
;
}
else
{
await
connection
.
query
(
`DELETE FROM welcome_channel WHERE guild ='
${
message
.
guild
.
id
}
'`
,
function
(
err
,
result
)
{
if
(
err
){
throw
err
;
};
});
message
.
channel
.
send
(
'
Successful!
'
).
catch
(
e
=>
{
return
;
});
};
}
else
if
(
!
message
.
mentions
.
channels
.
first
())
{
message
.
channel
.
send
(
errors
.
insufficient_args
).
catch
(
e
=>
{
return
;
});
}
else
if
(
message
.
mentions
.
channels
.
first
())
{
if
(
channel
==
"
none
"
)
{
connection
.
query
(
`INSERT INTO welcome_channel (guild, channel) VALUES ('
${
message
.
guild
.
id
}
', '
${
message
.
mentions
.
channels
.
first
().
id
}
')`
,
function
(
err
,
result
)
{
if
(
err
)
{
throw
err
;
};
});
}
else
{
const
prefixdb
=
await
new
Promise
((
resolve
,
reject
)
=>
{
connection
.
query
(
`SELECT prefix FROM prefixes WHERE guild ='
${
message
.
guild
.
id
}
'`
,
function
(
err
,
result
)
{
if
(
err
)
reject
(
err
);
resolve
(
result
);
});
});
var
prefix
;
if
(
prefixdb
.
length
<
1
)
{
prefix
=
config
.
prefix
;
}
else
{
prefix
=
prefixdb
[
0
].
prefix
;
};
message
.
channel
.
send
(
`Welcome channel is already existing. To reset type
\`
${
prefix
}
welcome-channel reset
\`
.`
).
catch
(
e
=>
{
return
;
});
};
};
};
module
.
exports
.
help
=
{
name
:
'
welcome-channel
'
,
aliases
:
[
'
welcome_channel
'
,
'
welcomechannel
'
]
};
This diff is collapsed.
Click to expand it.
errors.json
+
2
−
1
View file @
058a9c73
...
...
@@ -5,5 +5,6 @@
"unknown_error"
:
"An error occurred while executing this command."
,
"insufficient_args"
:
"You must specify all required args"
,
"cannot_send_embed"
:
"Cannot send an embed."
,
"owner_only"
:
"You don't own this bot."
"owner_only"
:
"You don't own this bot."
,
"not_existing_on_db"
:
"It's not existing on database, so you can't reset."
}
\ 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