但是情况略有不同。 这是我的构建。Gradle
plugins {
id'java'
id 'application'
id'com.github.johnrengelman.shadow' version '5.2.0'
}
mainClassName = 'me.bluedragonplayz2.dragonassistance.Bot'
version '1.0'
sourceCompatibility = JavaVersion.VERSION_14
apply plugin: 'java'
jar {
manifest {
attributes 'Main-Class': 'Bot'
}
}
repositories {
jcenter()
}
dependencies {
implementation 'com.sedmelluq:lavaplayer:1.3.50'
implementation group: 'net.dv8tion', name: 'JDA', version: '4.2.0_204'
implementation group: 'com.jagrosh', name: 'jda-utilities', version: '3.0.4'
implementation group: 'me.duncte123', name: 'botCommons', version: '1.0.88'
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
implementation group: 'org.xerial', name: 'sqlite-jdbc', version: '3.32.3.2'
implementation group: 'org.menudocs', name: 'paste-client-java', version: '1.1.1'
implementation 'io.github.cdimascio:java-dotenv:5.2.2'
implementation group: 'com.microsoft.sqlserver', name: 'mssql-jdbc', version: '8.4.1.jre14'
}
compileJava.options.encoding = 'UTF-8'
也是我的主类(不必费心尝试查找使用配置文件的令牌)
static void bot() throws LoginException, UnknownHostException {
EnumSet<GatewayIntent> intents = EnumSet.of(
GatewayIntent.GUILD_MESSAGES,
GatewayIntent.GUILD_BANS,
GatewayIntent.GUILD_EMOJIS,
GatewayIntent.GUILD_INVITES,
GatewayIntent.GUILD_MEMBERS,
GatewayIntent.GUILD_VOICE_STATES
);
CommandClientBuilder builder = new CommandClientBuilder();
builder.setActivity(Activity.watching("How to kill treble"))
.setOwnerId(Config.get("owner_id"))
.setPrefix(Config.get("prefix"))
.addCommand(new Ping())
.addCommand(new Eight_ball())
.addCommand(new kick())
.addCommand(new Ban())
.setHelpWord("help");
CommandClient client = builder.build();
String token;
if (java.net.Inet4Address.getLocalHost().getHostAddress().equalsIgnoreCase(Config.get("IP"))) {
token = Config.get("token");
} else {
token = Config.get("alt_token");
}
JDABuilder.create(token, intents)
.addEventListeners(new Listerner())
.addEventListeners(new Join())
.addEventListeners(new Kick())
.addEventListeners(new Sandbox())
.addEventListeners(new Guild_join())
.addEventListeners(new Setup())
.addEventListeners(client)
.build();
}
public static void main (String[]args) throws LoginException, UnknownHostException {
MsSQL mssql = new MsSQL();
mssql.MsSql();
bot();
Console cnsl= System.console();
if (cnsl == null) {
System.out.println(
"No console available");
return;
}
String input = "start";
while (!input.equals("stop"))
{
input = cnsl.readLine();
}
System.exit(0);
}
}
请帮助我,如果您需要更多信息,我真的找不到任何解决方案。