-
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.
Merge pull request #3 from orewaee/dev
New team and small fixes
- Loading branch information
Showing
7 changed files
with
66 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ plugins { | |
} | ||
|
||
group = "dev.orewaee" | ||
version = "0.3.1" | ||
version = "0.3.2" | ||
|
||
repositories { | ||
mavenCentral() | ||
|
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,49 @@ | ||
package dev.orewaee.bot; | ||
|
||
import dev.orewaee.account.Account; | ||
import net.dv8tion.jda.api.EmbedBuilder; | ||
import net.dv8tion.jda.api.entities.MessageEmbed; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; | ||
import net.dv8tion.jda.api.hooks.ListenerAdapter; | ||
|
||
import dev.orewaee.account.AccountManager; | ||
import dev.orewaee.account.JsonAccountManager; | ||
import dev.orewaee.config.Config; | ||
import dev.orewaee.config.TomlConfig; | ||
|
||
import java.util.Set; | ||
import java.util.StringJoiner; | ||
|
||
public class AccountsCommand extends ListenerAdapter { | ||
private final AccountManager accountManager = JsonAccountManager.getInstance(); | ||
|
||
private final Config config = TomlConfig.getInstance(); | ||
|
||
@Override | ||
public void onSlashCommandInteraction(@NotNull SlashCommandInteractionEvent event) { | ||
if (!event.getUser().getId().equals(config.adminDiscordId())) return; | ||
|
||
if (!event.getName().equals("accounts")) return; | ||
|
||
Set<Account> accounts = accountManager.getAccounts(); | ||
int quantity = accounts.size(); | ||
StringJoiner result = new StringJoiner("\n"); | ||
for (Account account : accounts) | ||
result.add( | ||
String.format("- `%s` ||%s||", account.name(), account.discordId()) | ||
); | ||
|
||
MessageEmbed embed = new EmbedBuilder() | ||
.setColor(0x5865f2) | ||
.setTitle(":page_with_curl: List of accounts") | ||
.setDescription( | ||
quantity == 0 ? "No accounts found at this time." : | ||
String.format("At the moment, %d accounts have been found.\n\n%s", quantity, result) | ||
) | ||
.build(); | ||
|
||
event.replyEmbeds(embed).queue(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,4 @@ lobby_server_name = "lobby" | |
bot_token = "" | ||
|
||
# Discord admin | ||
discord_admin_id = "" | ||
admin_discord_id = "" |