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
c86e4083
Commit
c86e4083
authored
Apr 17, 2021
by
Reviath
Browse files
Options
Downloads
Patches
Plain Diff
Added guild member remove event.
parent
17d9fe1c
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
events/memberremove.js
+36
-0
36 additions, 0 deletions
events/memberremove.js
main.js
+2
-0
2 additions, 0 deletions
main.js
with
38 additions
and
0 deletions
events/memberremove.js
0 → 100644
+
36
−
0
View file @
c86e4083
module
.
exports
=
{
guildmemberremove
:
(
client
,
connection
)
=>
{
client
.
on
(
'
guildMemberRemove
'
,
async
(
member
)
=>
{
let
channel_db
;
let
message_db
;
await
connection
.
query
(
`SELECT message FROM leave_message WHERE guild ='
${
member
.
guild
.
id
}
'`
,
function
(
err
,
result
)
{
if
(
err
){
throw
err
;
};
if
(
result
.
length
<
1
)
{
message_db
=
`<@
${
member
.
id
}
> left the server.`
;
}
else
{
message_db
=
result
[
0
].
message
;
};
});
await
connection
.
query
(
`SELECT channel FROM leave_channel WHERE guild ='
${
member
.
guild
.
id
}
'`
,
function
(
err
,
result
)
{
if
(
err
){
throw
err
;
};
if
(
result
.
length
<
1
)
{
return
;
}
else
{
channel_db
=
result
[
0
].
channel
;
const
channel
=
member
.
guild
.
channels
.
cache
.
get
(
channel_db
);
if
(
!
channel
)
{
return
;
};
channel
.
send
(
message_db
?
message_db
.
replace
(
'
{mention}
'
,
`
${
member
}
`
).
replace
(
'
{username}
'
,
`
${
member
.
user
.
username
}
`
)
:
``
).
catch
(
e
=>
{
return
;
});
}
});
});
}
};
This diff is collapsed.
Click to expand it.
main.js
+
2
−
0
View file @
c86e4083
...
@@ -5,6 +5,7 @@ const dbconfig = require('./dbconfig.json');
...
@@ -5,6 +5,7 @@ const dbconfig = require('./dbconfig.json');
const
ready
=
require
(
'
./events/ready
'
);
const
ready
=
require
(
'
./events/ready
'
);
const
message
=
require
(
'
./events/message
'
);
const
message
=
require
(
'
./events/message
'
);
const
memberadd
=
require
(
'
./events/memberadd
'
);
const
memberadd
=
require
(
'
./events/memberadd
'
);
const
memberremove
=
require
(
'
./events/memberremove
'
);
const
fs
=
require
(
'
fs
'
);
const
fs
=
require
(
'
fs
'
);
const
mysql
=
require
(
'
mysql
'
);
const
mysql
=
require
(
'
mysql
'
);
...
@@ -27,6 +28,7 @@ client.aliases = new Discord.Collection();
...
@@ -27,6 +28,7 @@ client.aliases = new Discord.Collection();
ready
.
ready
(
client
);
ready
.
ready
(
client
);
message
.
message
(
client
,
config
,
Discord
,
connection
);
message
.
message
(
client
,
config
,
Discord
,
connection
);
memberadd
.
guildmemberadd
(
client
,
connection
);
memberadd
.
guildmemberadd
(
client
,
connection
);
memberremove
.
guildmemberremove
(
client
,
connection
);
fs
.
readdir
(
"
./commands/
"
,
(
err
,
files
)
=>
{
fs
.
readdir
(
"
./commands/
"
,
(
err
,
files
)
=>
{
...
...
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