This repository has been archived by the owner on Nov 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes: - Update project version to 1.0 - Add ModuleAbout, ModuleScreenshare (#8) - Migrate ModuleInfo aliases from String[] to immutable List<String> - Enforce all-lowercase command names / aliases - Handle aliases in CommandRegistry (#3) - Move InvalidModuleExceptionTest to correct package - Reformat some code - Fix permission check to consider Permission.ADMINISTRATOR - Update Travis release uploads to support refactored build tools - Add Linux ARM32 build
- Loading branch information
Showing
18 changed files
with
148 additions
and
76 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
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
45 changes: 45 additions & 0 deletions
45
src/main/java/com/github/coleb1911/ghost2/commands/modules/info/ModuleAbout.java
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,45 @@ | ||
package com.github.coleb1911.ghost2.commands.modules.info; | ||
|
||
import com.github.coleb1911.ghost2.commands.meta.CommandContext; | ||
import com.github.coleb1911.ghost2.commands.meta.Module; | ||
import com.github.coleb1911.ghost2.commands.meta.ModuleInfo; | ||
import com.github.coleb1911.ghost2.shared.Constants; | ||
import discord4j.core.object.entity.Member; | ||
import org.apache.commons.lang3.time.DurationFormatUtils; | ||
|
||
import javax.validation.constraints.NotNull; | ||
import java.time.Duration; | ||
import java.time.Instant; | ||
|
||
public final class ModuleAbout extends Module { | ||
private static final String GITHUB_URL = "https://github.com/cbryant02/ghost2"; | ||
private static final String FLAVOR_TEXT = "Want to help contribute? Visit our GitHub: " + GITHUB_URL + "\n" + | ||
"You can also report bugs there by opening an issue, or by messaging yaboired#8927."; | ||
private static final String FIELD_ID = "\uD83C\uDD94 My ID"; | ||
private static final String FIELD_TAG = "\u0023\u20E3 My tag"; | ||
private static final String FIELD_SERVER_TIME = "\u23F1 Time in this server"; | ||
private static final String FOOTER = "ghost2 v" + Constants.VERSION_STRING; | ||
|
||
public ModuleAbout() { | ||
super(new ModuleInfo.Builder(ModuleAbout.class) | ||
.withName("about") | ||
.withDescription("Information about the bot")); | ||
} | ||
|
||
@Override | ||
public void invoke(@NotNull CommandContext ctx) { | ||
Member me = ctx.getSelf(); | ||
|
||
Duration timeInServer = Duration.between(me.getJoinTime(), Instant.now()); | ||
String timeFormatted = DurationFormatUtils.formatDuration(timeInServer.toMillis(), "dd 'days', HH 'hours', mm 'minutes'"); | ||
|
||
ctx.getChannel().createEmbed(embedCreateSpec -> embedCreateSpec | ||
.setAuthor(me.getUsername(), "https://github.com/cbryant02/ghost2", me.getAvatarUrl()) | ||
.setTitle("About") | ||
.setDescription(FLAVOR_TEXT) | ||
.addField(FIELD_ID, me.getId().asString(), false) | ||
.addField(FIELD_TAG, me.getUsername() + "#" + me.getDiscriminator(), false) | ||
.addField(FIELD_SERVER_TIME, timeFormatted, false) | ||
.setFooter(FOOTER, null)).subscribe(); | ||
} | ||
} |
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
Oops, something went wrong.