Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
Voice Bot
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
Voice Bot
Commits
2495c1ec
Commit
2495c1ec
authored
Aug 26, 2021
by
Levatax
Browse files
Options
Downloads
Patches
Plain Diff
added kick command
parent
223bd88f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
command.go
+70
-0
70 additions, 0 deletions
command.go
with
70 additions
and
0 deletions
command.go
+
70
−
0
View file @
2495c1ec
...
...
@@ -145,4 +145,74 @@ func init() {
context
.
SendMessage
(
"Action completed."
)
},
})
m
.
Route
(
&
multiplexer
.
Route
{
Pattern
:
"kick"
,
AliasPatterns
:
[]
string
{
"k"
,
"dc"
},
Description
:
"Kick an user from channel."
,
Category
:
system
,
Handler
:
func
(
context
*
multiplexer
.
Context
)
{
if
len
(
context
.
Fields
)
<
2
{
// Return if unexpected amount of arguments.
context
.
SendMessage
(
"Expecting user."
)
return
}
// Get member
member
:=
context
.
GetMember
(
context
.
Fields
[
1
])
if
member
==
nil
{
context
.
SendMessage
(
"Expecting member."
)
return
}
// Get instance
instance
,
ok
:=
instancesUser
[
context
.
User
.
ID
]
if
!
ok
{
context
.
SendMessage
(
"You do not own any volatile channel."
)
return
}
// Perform action
if
!
instance
.
actionPerform
(
"kick"
,
func
()
bool
{
// Check if member is in the channel
state
,
err
:=
context
.
Session
.
State
.
VoiceState
(
member
.
GuildID
,
member
.
User
.
ID
)
if
err
!=
nil
{
log
.
Errorf
(
"Error getting state of at guild %s on behalf of member %s, %s"
,
member
.
GuildID
,
member
.
User
.
ID
,
err
)
return
false
}
if
state
.
ChannelID
!=
instance
.
Channel
.
ID
{
context
.
SendMessage
(
"The user is not in your volatile channel"
)
return
false
}
// Perform change
err2
:=
context
.
Session
.
GuildMemberMove
(
member
.
GuildID
,
member
.
User
.
ID
,
nil
)
if
err2
!=
nil
{
log
.
Errorf
(
"Error disconnecting user at guild %s on behalf of member %s, %s"
,
member
.
GuildID
,
member
.
User
.
ID
,
err
)
return
false
}
err3
:=
context
.
Session
.
ChannelPermissionSet
(
instance
.
Channel
.
ID
,
member
.
User
.
ID
,
1
,
1024
,
1048576
)
if
err3
!=
nil
{
log
.
Errorf
(
"Error changing permissions for user at guild %s on behalf of member %s, %s"
,
member
.
GuildID
,
member
.
User
.
ID
,
err
)
return
false
}
return
true
},
context
.
SendMessage
)
{
return
}
log
.
Infof
(
"Kick user from volatile channel #%s (%s) to %v on behalf of %s#%s (%s)."
,
instance
.
Channel
.
Name
,
instance
.
Channel
.
ID
,
instance
.
Initiator
.
User
.
Username
,
instance
.
Initiator
.
User
.
Discriminator
,
instance
.
Initiator
.
User
.
ID
)
context
.
SendMessage
(
"Action completed."
)
},
})
}
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