Page Menu
Home
desp's stash
Search
Configure Global Search
Log In
Files
F374155
Shutdown.java
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
Shutdown.java
View Options
package
me.despawningbone.discordbot.command.admin
;
import
me.despawningbone.discordbot.DiscordBot
;
import
me.despawningbone.discordbot.command.Command
;
import
me.despawningbone.discordbot.command.CommandResult
;
import
me.despawningbone.discordbot.command.CommandResult.CommandResultType
;
import
me.despawningbone.discordbot.command.music.AudioTrackHandler
;
import
me.despawningbone.discordbot.command.music.Music
;
import
net.dv8tion.jda.api.entities.Message
;
import
net.dv8tion.jda.api.entities.channel.concrete.TextChannel
;
import
net.dv8tion.jda.api.entities.User
;
public
class
Shutdown
extends
Command
{
public
Shutdown
()
{
this
.
desc
=
"Shut down the bot"
;
this
.
usage
=
""
;
this
.
botUserLevel
=
BotUserLevel
.
BOT_OWNER
.
ordinal
();
}
@Override
public
CommandResult
execute
(
TextChannel
channel
,
User
author
,
Message
msg
,
String
[]
args
)
{
channel
.
sendMessage
(
"Bye!"
).
queue
();
System
.
out
.
println
(
"\nShutting down the bot...\n"
);
//shut down audio system gracefully first if exists
AudioTrackHandler
ap
=
((
Music
)
DiscordBot
.
commands
.
get
(
"music"
)).
getAudioTrackHandler
();
if
(
ap
!=
null
)
ap
.
shutdown
();
new
Thread
(()
->
DiscordBot
.
mainJDA
.
shutdown
()).
start
();
//new thread needed to actually shutdown correctly since or else its stuck waiting for the event to finish
return
new
CommandResult
(
CommandResultType
.
SUCCESS
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Sun, Aug 3, 4:11 AM (42 m, 31 s)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
07/48/29359e9855c9ef2b99b42a12f0f3
Attached To
rDESB despbot
Event Timeline
Log In to Comment