From 65798840be5bbbc131c8977566a9a40dc3f51d32 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 30 Jul 2021 12:31:04 +0200 Subject: [PATCH] Add TeamCommand Fix IngameChatListener at everyone and at here --- .../bungeecore/bot/SteamwarDiscordBot.java | 2 ++ .../bungeecore/bot/commands/BanCommand.java | 8 ++--- .../bungeecore/bot/commands/MuteCommand.java | 8 ++--- .../bungeecore/bot/commands/TeamCommand.java | 35 +++++++++++++++++++ .../bungeecore/bot/commands/WhoisCommand.java | 4 +-- .../bot/listeners/IngameChatListener.java | 2 +- .../bot/listeners/SlashCommandListener.java | 7 ++++ 7 files changed, 55 insertions(+), 11 deletions(-) create mode 100644 src/de/steamwar/bungeecore/bot/commands/TeamCommand.java diff --git a/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java b/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java index dda49caa..241ce909 100644 --- a/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java +++ b/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java @@ -22,6 +22,7 @@ package de.steamwar.bungeecore.bot; import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.bot.commands.BanCommand; import de.steamwar.bungeecore.bot.commands.MuteCommand; +import de.steamwar.bungeecore.bot.commands.TeamCommand; import de.steamwar.bungeecore.bot.commands.WhoisCommand; import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig; import de.steamwar.bungeecore.bot.events.EventManager; @@ -108,6 +109,7 @@ public class SteamwarDiscordBot { commands.addCommands(new MuteCommand()); commands.addCommands(new BanCommand()); commands.addCommands(new WhoisCommand()); + commands.addCommands(new TeamCommand()); commands.complete(); } diff --git a/src/de/steamwar/bungeecore/bot/commands/BanCommand.java b/src/de/steamwar/bungeecore/bot/commands/BanCommand.java index d0924b07..65928f04 100644 --- a/src/de/steamwar/bungeecore/bot/commands/BanCommand.java +++ b/src/de/steamwar/bungeecore/bot/commands/BanCommand.java @@ -25,10 +25,10 @@ import net.dv8tion.jda.api.interactions.commands.build.CommandData; public class BanCommand extends CommandData { public BanCommand() { - super("ban", "Ban a user. Requires permission to ban users."); + super("ban", "Banne einen Nutzer, wenn du die Rechte hast."); - addOption(OptionType.STRING, "user", "The user to bam", true); - addOption(OptionType.STRING, "time", "The time to ban until", true); - addOption(OptionType.STRING, "reason", "The reason to ban", true); + addOption(OptionType.STRING, "user", "Der Benutzer", true); + addOption(OptionType.STRING, "time", "Bis Wann", true); + addOption(OptionType.STRING, "reason", "Warum", true); } } diff --git a/src/de/steamwar/bungeecore/bot/commands/MuteCommand.java b/src/de/steamwar/bungeecore/bot/commands/MuteCommand.java index 18f6074f..4eb9d99a 100644 --- a/src/de/steamwar/bungeecore/bot/commands/MuteCommand.java +++ b/src/de/steamwar/bungeecore/bot/commands/MuteCommand.java @@ -25,10 +25,10 @@ import net.dv8tion.jda.api.interactions.commands.build.CommandData; public class MuteCommand extends CommandData { public MuteCommand() { - super("mute", "Mute a user. Requires permission to mute users."); + super("mute", "Mute einen Nutzer, wenn du die Rechte hast."); - addOption(OptionType.STRING, "user", "The user to mute", true); - addOption(OptionType.STRING, "time", "The time to mute until", true); - addOption(OptionType.STRING, "reason", "The reason to mute", true); + addOption(OptionType.STRING, "user", "Der Benutzer", true); + addOption(OptionType.STRING, "time", "Bis Wann", true); + addOption(OptionType.STRING, "reason", "Warum", true); } } diff --git a/src/de/steamwar/bungeecore/bot/commands/TeamCommand.java b/src/de/steamwar/bungeecore/bot/commands/TeamCommand.java new file mode 100644 index 00000000..3ae288de --- /dev/null +++ b/src/de/steamwar/bungeecore/bot/commands/TeamCommand.java @@ -0,0 +1,35 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bungeecore.bot.commands; + +import net.dv8tion.jda.api.interactions.commands.OptionType; +import net.dv8tion.jda.api.interactions.commands.build.CommandData; +import net.dv8tion.jda.api.interactions.commands.build.SubcommandData; + +public class TeamCommand extends CommandData { + + public TeamCommand() { + super("team", "Alle Team bezogenen Befehle"); + + addSubcommands(new SubcommandData("info", "Infos über das Team oder deins") + .addOption(OptionType.STRING, "team", "Name oder Kuerzel", false) + ); + } +} diff --git a/src/de/steamwar/bungeecore/bot/commands/WhoisCommand.java b/src/de/steamwar/bungeecore/bot/commands/WhoisCommand.java index 390a4008..a2ea9d8a 100644 --- a/src/de/steamwar/bungeecore/bot/commands/WhoisCommand.java +++ b/src/de/steamwar/bungeecore/bot/commands/WhoisCommand.java @@ -25,8 +25,8 @@ import net.dv8tion.jda.api.interactions.commands.build.CommandData; public class WhoisCommand extends CommandData { public WhoisCommand() { - super("whois", "Check a users id and stuff"); + super("whois", "Der whois Befehl"); - addOption(OptionType.STRING, "user", "The user to get", true); + addOption(OptionType.STRING, "user", "Der Benutzer", true); } } diff --git a/src/de/steamwar/bungeecore/bot/listeners/IngameChatListener.java b/src/de/steamwar/bungeecore/bot/listeners/IngameChatListener.java index 5cc8b046..6ec97890 100644 --- a/src/de/steamwar/bungeecore/bot/listeners/IngameChatListener.java +++ b/src/de/steamwar/bungeecore/bot/listeners/IngameChatListener.java @@ -62,7 +62,7 @@ public class IngameChatListener extends BasicDiscordListener { TextChannel textChannel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.INGAME_CHANNEL); assert textChannel != null; MessageBuilder messageBuilder = new MessageBuilder(); - messageBuilder.append(message.replace("&", "")); + messageBuilder.append(message.replace("&", "").replace("@everyone", "").replace("@here", "")); textChannel.sendMessage(messageBuilder.build()).complete(); } } diff --git a/src/de/steamwar/bungeecore/bot/listeners/SlashCommandListener.java b/src/de/steamwar/bungeecore/bot/listeners/SlashCommandListener.java index 8389627a..4dda95d8 100644 --- a/src/de/steamwar/bungeecore/bot/listeners/SlashCommandListener.java +++ b/src/de/steamwar/bungeecore/bot/listeners/SlashCommandListener.java @@ -46,6 +46,9 @@ public class SlashCommandListener extends BasicDiscordListener { case "whois": whois(event); break; + case "team": + team(event); + break; default: return; } @@ -135,6 +138,10 @@ public class SlashCommandListener extends BasicDiscordListener { event.replyEmbeds(embedBuilder.build()).setEphemeral(true).complete(); } + private void team(SlashCommandEvent event) { + + } + private boolean testPermission(SlashCommandEvent event) { Member member = event.getMember(); SteamwarUser steamwarUser = SteamwarUser.get(member.getIdLong());