-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
160 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
px32-bot-func/src/main/kotlin/net/projecttl/p/x32/func/Loader.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import java.io.File | ||
import java.io.FileInputStream | ||
import java.util.* | ||
import kotlin.reflect.KProperty | ||
|
||
object Conf { | ||
private fun useConf(): ConfDel { | ||
return ConfDel() | ||
} | ||
|
||
val owner: String by useConf() | ||
} | ||
|
||
private class ConfDel { | ||
private val props = Properties() | ||
|
||
init { | ||
val file = File("config.properties") | ||
props.load(FileInputStream(file)) | ||
} | ||
|
||
operator fun getValue(thisRef: Any?, property: KProperty<*>): String { | ||
return props.getProperty(property.name).toString() | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
px32-bot-module/src/main/kotlin/net/projecttl/p/x32/func/General.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package net.projecttl.p.x32.func | ||
|
||
import net.dv8tion.jda.api.JDABuilder | ||
import net.projecttl.p.x32.api.Plugin | ||
import net.projecttl.p.x32.api.command.CommandHandler | ||
import net.projecttl.p.x32.func.command.Avatar | ||
import net.projecttl.p.x32.func.command.MsgPurge | ||
import net.projecttl.p.x32.func.command.MsgLength | ||
import net.projecttl.p.x32.func.command.Ping | ||
import net.projecttl.p.x32.func.handler.Ready | ||
|
||
|
||
class General : Plugin() { | ||
override fun onLoad() { | ||
logger.info("Created by Project_IO") | ||
logger.info("Hello! This is Px32's general module!") | ||
|
||
addHandler(Ready) | ||
addHandler(with(CommandHandler()) { | ||
addCommand(Avatar) | ||
addCommand(MsgLength) | ||
addCommand(Ping) | ||
addCommand(MsgPurge) | ||
|
||
this | ||
}) | ||
} | ||
|
||
override fun destroy() { | ||
logger.info("bye!") | ||
} | ||
} | ||
|
||
|
File renamed without changes.
File renamed without changes.
36 changes: 36 additions & 0 deletions
36
px32-bot-module/src/main/kotlin/net/projecttl/p/x32/func/command/MsgPurge.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package net.projecttl.p.x32.func.command | ||
|
||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent | ||
import net.dv8tion.jda.api.interactions.commands.OptionType | ||
import net.dv8tion.jda.api.interactions.commands.build.CommandData | ||
import net.dv8tion.jda.internal.interactions.CommandDataImpl | ||
import net.projecttl.p.x32.api.command.GlobalCommand | ||
|
||
object MsgPurge : GlobalCommand { | ||
override val data = CommandData.fromData( | ||
CommandDataImpl("purge", "n개의 메시지를 채널에서 삭제해요").apply { | ||
addOption(OptionType.INTEGER, "n", "n개만큼 메시지가 삭제 됩니다", true) | ||
}.toData() | ||
) | ||
|
||
override suspend fun execute(ev: SlashCommandInteractionEvent) { | ||
val n = ev.getOption("n")!!.asInt | ||
if (n !in 1..100) { | ||
return ev.reply(":warning: 1 부터 100까지 가능해요").setEphemeral(true).queue() | ||
} | ||
|
||
if (ev.user.id != Conf.owner) { | ||
ev.reply(":warning: 이 명령어는 봇 관리자만 사용 가능해요").setEphemeral(true).queue() | ||
return | ||
} | ||
|
||
try { | ||
ev.channel.iterableHistory.takeAsync(n).thenAccept(ev.channel::purgeMessages) | ||
} catch (ex: Exception) { | ||
ex.printStackTrace() | ||
return ev.reply(":warning: 메시지 삭제 도중에 문제가 발생 했어요").queue() | ||
} | ||
|
||
ev.reply(":white_check_mark: `${n}`개의 메시지를 삭제 했어요").queue() | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "${project.name}", | ||
"version": "${project.version}", | ||
"main": "net.projecttl.p.x32.func.General" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
rootProject.name = "px32-bot" | ||
include("px32-bot-core") | ||
include("px32-bot-api") | ||
include("px32-bot-func") | ||
include("px32-bot-module") | ||
include("sample-plugin") |