Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Ash
Discord Bot
Commits
b19d64b6
Unverified
Commit
b19d64b6
authored
Aug 16, 2019
by
tec
Browse files
Make command prefix more easily variable
parent
cf3d7abe
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/config.rs
View file @
b19d64b6
...
...
@@ -21,6 +21,8 @@ pub static TIEBREAKER_ROLE: u64 = 607509283483025409;
pub
static
UNREGISTERED_MEMBER_ROLE
:
u64
=
608282247350714408
;
pub
static
REGISTERED_MEMBER_ROLE
:
u64
=
608282133118582815
;
pub
static
COMMAND_PREFIX
:
&
str
=
"!"
;
pub
static
FOR_VOTE
:
&
str
=
"👍"
;
pub
static
AGAINST_VOTE
:
&
str
=
"👎"
;
pub
static
ABSTAIN_VOTE
:
&
str
=
"🙊"
;
...
...
src/main.rs
View file @
b19d64b6
...
...
@@ -26,7 +26,7 @@ impl EventHandler for Handler {
// Event handlers are dispatched through a threadpool, and so multiple
// events can be dispatched simultaneously.
fn
message
(
&
self
,
ctx
:
Context
,
msg
:
Message
)
{
if
msg
.content
.starts_with
(
"!"
)
{
if
msg
.content
.starts_with
(
config
::
COMMAND_PREFIX
)
{
let
message_content
:
Vec
<
_
>
=
msg
.content
[
1
..
]
.splitn
(
2
,
' '
)
.collect
();
match
message_content
[
0
]
{
"register"
=>
{
...
...
@@ -49,9 +49,14 @@ impl EventHandler for Handler {
}
"help"
=>
{
let
mut
message
=
MessageBuilder
::
new
();
message
.push_line
(
"Use !move <action> to make a circular motion"
);
message
.push_line
(
"Use !poll <proposal> to see what people think about something"
);
message
.push_line
(
format!
(
"Use {}move <action> to make a circular motion"
,
config
::
COMMAND_PREFIX
));
message
.push_line
(
format!
(
"Use {}poll <proposal> to see what people think about something"
,
config
::
COMMAND_PREFIX
));
e!
(
"Error sending message: {:?}"
,
msg
.channel_id
.say
(
&
ctx
.http
,
message
.build
())
...
...
@@ -60,8 +65,10 @@ impl EventHandler for Handler {
_
=>
{
e!
(
"Error sending message: {:?}"
,
msg
.channel_id
.say
(
&
ctx
.http
,
"Unrecognised command. Try !help"
)
msg
.channel_id
.say
(
&
ctx
.http
,
format!
(
"Unrecognised command. Try {}help"
,
config
::
COMMAND_PREFIX
)
)
);
}
}
...
...
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