Skip to content

Commit

Permalink
Merge branch 'release/0.8.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
kosugikun committed Mar 12, 2023
2 parents 062e92f + b4ba833 commit 5426d75
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 1,151 deletions.
16 changes: 8 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
<groupId>com.jagrosh</groupId>
<artifactId>JMusicBot</artifactId>
<!-- バージョン装飾子参考の参考に: https://kengotoda.gitbooks.io/what-is-maven/deploy/snapshot-and-stable.html -->
<version>0.8.0</version>
<version>0.8.1</version>
<packaging>jar</packaging>

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>dv8tion</id>
<name>m2-dv8tion</name>
Expand All @@ -19,10 +23,6 @@
<name>bintray</name>
<url>https://jcenter.bintray.com</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>chew-m2-snapshots</id>
<url>https://m2.chew.pro/snapshots/</url>
Expand All @@ -42,12 +42,12 @@
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.2</version>
<version>5.0.0-beta.5</version>
</dependency>
<dependency>
<groupId>com.github.Cosgy-Dev</groupId>
<artifactId>lavaplayer-fork</artifactId>
<version>original-856c01650a-1</version>
<artifactId>lavaplayer-cosgy</artifactId>
<version>1.4.1</version>
</dependency>
<!--
<dependency>
Expand Down
78 changes: 9 additions & 69 deletions src/main/java/com/jagrosh/jmusicbot/JMusicBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import net.dv8tion.jda.api.OnlineStatus;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.Activity;
import net.dv8tion.jda.api.exceptions.InvalidTokenException;
import net.dv8tion.jda.api.requests.GatewayIntent;
import net.dv8tion.jda.api.utils.cache.CacheFlag;
import org.slf4j.Logger;
Expand All @@ -52,13 +53,13 @@
* @author John Grosh (jagrosh)
*/
public class JMusicBot {
public final static String PLAY_EMOJI = "\u25B6"; // ▶
public final static String PAUSE_EMOJI = "\u23F8"; // ⏸
public final static String STOP_EMOJI = "\u23F9"; // ⏹
public final static String PLAY_EMOJI = ""; // ▶
public final static String PAUSE_EMOJI = ""; // ⏸
public final static String STOP_EMOJI = ""; // ⏹
public final static Permission[] RECOMMENDED_PERMS = {Permission.MESSAGE_SEND, Permission.VIEW_CHANNEL, Permission.MESSAGE_HISTORY, Permission.MESSAGE_ADD_REACTION,
Permission.MESSAGE_EMBED_LINKS, Permission.MESSAGE_ATTACH_FILES, Permission.MESSAGE_MANAGE, Permission.MESSAGE_EXT_EMOJI,
Permission.MANAGE_CHANNEL, Permission.VOICE_CONNECT, Permission.VOICE_SPEAK, Permission.NICKNAME_CHANGE};
public final static GatewayIntent[] INTENTS = {GatewayIntent.DIRECT_MESSAGES, GatewayIntent.GUILD_MESSAGES, GatewayIntent.GUILD_MESSAGE_REACTIONS, GatewayIntent.GUILD_VOICE_STATES, GatewayIntent.GUILD_EMOJIS_AND_STICKERS, GatewayIntent.MESSAGE_CONTENT};
public final static GatewayIntent[] INTENTS = {GatewayIntent.DIRECT_MESSAGES, GatewayIntent.GUILD_MESSAGES, GatewayIntent.GUILD_MESSAGE_REACTIONS, GatewayIntent.GUILD_VOICE_STATES, GatewayIntent.GUILD_EMOJIS_AND_STICKERS};
public static boolean CHECK_UPDATE = true;
public static boolean COMMAND_AUDIT_ENABLED = false;

Expand Down Expand Up @@ -118,7 +119,7 @@ public static void main(String[] args) {
Bot.INSTANCE = bot;

AboutCommand aboutCommand = new AboutCommand(Color.BLUE.brighter(),
"[簡単にホストできる!](https://github.com/Cosgy-Dev/MusicBot-JP-java)JMusicBot JP(v" + version + ")",
"[JMusicBot JP(v" + version + ")](https://github.com/Cosgy-Dev/MusicBot-JP-java)",
new String[]{"高品質の音楽再生", "FairQueue™テクノロジー", "自分で簡単にホスト"},
RECOMMENDED_PERMS);
aboutCommand.setIsAuthor(false);
Expand All @@ -139,68 +140,6 @@ public static void main(String[] args) {
cb.setServerInvite("https://discord.gg/MjNfC6TK2y");
}

List<Command> commandList = new ArrayList<Command>() {{
//その他
add(new HelpCmd(bot));
add(aboutCommand);
if (config.isUseInviteCommand()) {
add(new InviteCommand());
}
add(new PingCommand());
add(new SettingsCmd(bot));
if (config.getCosgyDevHost()) add(new InfoCommand(bot));
// General
add(new ServerInfo());
//add(new UserInfo());
add(new CashCmd(bot));
// Music
add(new LyricsCmd(bot));
add(new NowplayingCmd(bot));
add(new PlayCmd(bot));
add(new PlaylistsCmd(bot));
add(new MylistCmd(bot));
//add(new QueueCmd(bot));
add(new QueueCmd(bot));
add(new RemoveCmd(bot));
add(new SearchCmd(bot));
add(new SCSearchCmd(bot));
add(new NicoSearchCmd(bot));
add(new ShuffleCmd(bot));
add(new SkipCmd(bot));
add(new VolumeCmd(bot));
// DJ
add(new ForceRemoveCmd(bot));
add(new ForceskipCmd(bot));
add(new NextCmd(bot));
add(new MoveTrackCmd(bot));
add(new PauseCmd(bot));
add(new PlaynextCmd(bot));
//add(new RepeatCmd(bot));
add(new RepeatCmd(bot));
add(new SkipToCmd(bot));
add(new PlaylistCmd(bot));
add(new StopCmd(bot));
//add(new VolumeCmd(bot));
// Admin
add(new PrefixCmd(bot));
add(new SetdjCmd(bot));
add(new SkipratioCmd(bot));
add(new SettcCmd(bot));
add(new SetvcCmd(bot));
add(new AutoplaylistCmd(bot));
add(new ServerListCmd(bot));
// Owner
add(new DebugCmd(bot));
add(new SetavatarCmd(bot));
add(new SetgameCmd(bot));
add(new SetnameCmd(bot));
add(new SetstatusCmd(bot));
add(new PublistCmd(bot));
add(new ShutdownCmd(bot));
//add(new LeaveCmd(bot));
}};
cb.addCommands(commandList.toArray(new Command[0]));

// スラッシュコマンドの実装
List<SlashCommand> slashCommandList = new ArrayList<>() {{
add(new HelpCmd(bot));
Expand Down Expand Up @@ -263,6 +202,7 @@ public static void main(String[] args) {
//add(new LeaveCmd(bot));
}};

cb.addCommands(slashCommandList.toArray(new Command[0]));
cb.addSlashCommands(slashCommandList.toArray(new SlashCommand[0]));

if (config.useEval())
Expand Down Expand Up @@ -304,13 +244,13 @@ else if (config.getGame().getName().toLowerCase().matches("(none|なし)")) {
.setBulkDeleteSplittingEnabled(true)
.build();
bot.setJDA(jda);
} /*catch (LoginException ex) {
} catch (InvalidTokenException ex) {
prompt.alert(Prompt.Level.ERROR, "JMusicBot", ex + "\n" +
"正しい設定ファイルを編集していることを確認してください。Botトークンでのログインに失敗しました。" +
"正しいBotトークンを入力してください。(CLIENT SECRET ではありません!)\n" +
"設定ファイルの場所: " + config.getConfigLocation());
System.exit(1);
}*/ catch (IllegalArgumentException ex) {
} catch (IllegalArgumentException ex) {
prompt.alert(Prompt.Level.ERROR, "JMusicBot", "設定の一部が無効です:" + ex + "\n" +
"設定ファイルの場所: " + config.getConfigLocation());
System.exit(1);
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/jagrosh/jmusicbot/Listener.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel;
import net.dv8tion.jda.api.events.guild.voice.GuildVoiceUpdateEvent;
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
import net.dv8tion.jda.api.events.message.MessageDeleteEvent;
import net.dv8tion.jda.api.events.session.ReadyEvent;
import net.dv8tion.jda.api.events.session.ShutdownEvent;
Expand Down Expand Up @@ -155,6 +156,11 @@ public void onGuildVoiceJoin(@NotNull GuildVoiceUpdateEvent event) {
}
}

@Override
public void onButtonInteraction(@NotNull ButtonInteractionEvent event) {

}

@Override
public void onShutdown(@NotNull ShutdownEvent event) {
bot.shutdown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ private Settings createDefaultSettings() {
}

protected void writeSettings() {
JSONObject obj = new JSONObject();
settings.keySet().forEach(key -> {
JSONObject o = new JSONObject();
var obj = new JSONObject();
for (Long key : settings.keySet()) {
var o = new JSONObject();
Settings s = settings.get(key);
if (s.textId != 0)
o.put("text_channel_id", Long.toString(s.textId));
Expand All @@ -114,7 +114,7 @@ protected void writeSettings() {
if (s.getSkipRatio() != SKIP_RATIO)
o.put("skip_ratio", s.getSkipRatio());
obj.put(Long.toString(key), o);
});
}
try {
Files.write(OtherUtil.getPath("serversettings.json"), obj.toString(4).getBytes());
} catch (IOException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,16 @@ protected void execute(SlashCommandEvent event) {
}
EmbedBuilder builder = new EmbedBuilder();
builder.setColor(event.getGuild() == null ? color : event.getGuild().getSelfMember().getColor());
builder.setAuthor("" + event.getJDA().getSelfUser().getName() + "について!", null, event.getJDA().getSelfUser().getAvatarUrl());
builder.setAuthor("" + event.getJDA().getSelfUser().getName() + "についての情報", null, event.getJDA().getSelfUser().getAvatarUrl());
String CosgyOwner = "Cosgy Devが運営、開発をしています。";
String author = event.getJDA().getUserById(event.getClient().getOwnerId()) == null ? "<@" + event.getClient().getOwnerId() + ">"
: Objects.requireNonNull(event.getJDA().getUserById(event.getClient().getOwnerId())).getName();
StringBuilder descr = new StringBuilder().append("こんにちは! **").append(event.getJDA().getSelfUser().getName()).append("**です。 ")
.append(description).append("は、").append(JDAUtilitiesInfo.AUTHOR + "の[コマンド拡張](" + JDAUtilitiesInfo.GITHUB + ") (")
.append(JDAUtilitiesInfo.VERSION).append(")と[JDAライブラリ](https://github.com/DV8FromTheWorld/JDA) (")
.append(description).append("は、").append("[" + JDAUtilitiesInfo.AUTHOR + "](https://github.com/JDA-Applications)の[Commands Extension](" + JDAUtilitiesInfo.GITHUB + ") (")
.append(JDAUtilitiesInfo.VERSION).append(")と[JDA library](https://github.com/DV8FromTheWorld/JDA) (")
.append(JDAInfo.VERSION).append(")を使用しており、").append((IS_AUTHOR ? CosgyOwner : author + "が所有しています。"))
.append(event.getJDA().getSelfUser().getName()).append("についての質問などは[Cosgy Dev公式チャンネル](https://discord.gg/RBpkHxf)へお願いします。")
.append("\nこのボットの使用方法は`").append(event.getClient().getTextualPrefix()).append(event.getClient().getHelpWord())
.append("\nこのボットの使用方法は`").append("/help")
.append("`で確認することができます。").append("\n\n機能の特徴: ```css");
for (String feature : features)
descr.append("\n").append(event.getClient().getSuccess().startsWith("<") ? REPLACEMENT_ICON : event.getClient().getSuccess()).append(" ").append(feature);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
import net.dv8tion.jda.api.exceptions.PermissionException;
import net.dv8tion.jda.api.interactions.InteractionHook;
import net.dv8tion.jda.api.interactions.commands.OptionType;
Expand Down Expand Up @@ -78,6 +79,9 @@ public PlayCmd(Bot bot) {

@Override
public void doCommand(CommandEvent event) {



if (event.getArgs().isEmpty() && event.getMessage().getAttachments().isEmpty()) {
AudioHandler handler = (AudioHandler) event.getGuild().getAudioManager().getSendingHandler();
if (handler.getPlayer().getPlayingTrack() != null && handler.getPlayer().isPaused()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Cosgy Dev ([email protected]).
* Copyright 2023 Cosgy Dev ([email protected]).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,20 +14,21 @@
* limitations under the License.
*/

package dev.cosgy.jmusicbot.slashcommands.admin;
package dev.cosgy.jmusicbot.slashcommands.owner;

import com.jagrosh.jdautilities.command.CommandEvent;
import com.jagrosh.jdautilities.command.SlashCommandEvent;
import com.jagrosh.jmusicbot.Bot;
import dev.cosgy.jmusicbot.slashcommands.AdminCommand;
import dev.cosgy.jmusicbot.slashcommands.OwnerCommand;
import net.dv8tion.jda.api.entities.Guild;

import java.util.List;

/**
* @author Kosugi_kun
*/
public class ServerListCmd extends AdminCommand {
public class ServerListCmd extends OwnerCommand {
protected Bot bot;

public ServerListCmd(Bot bot) {
Expand All @@ -37,11 +38,6 @@ public ServerListCmd(Bot bot) {

@Override
protected void execute(SlashCommandEvent event) {
if (checkAdminPermission(event.getClient(), event)) {
event.reply(event.getClient().getWarning() + "権限がないため実行できません。").queue();
return;
}

List<Guild> guilds = event.getJDA().getGuilds();

StringBuilder stringBuilder = new StringBuilder();
Expand Down
Loading

0 comments on commit 5426d75

Please sign in to comment.