Automatically get client ID for link, improvements

Literally 2 improvements
This commit is contained in:
Norbi Peti 2019-08-26 22:26:10 +02:00
parent e4d5dcd0a2
commit ea0ef88068
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
4 changed files with 11 additions and 5 deletions

View file

@ -142,9 +142,13 @@ public class DiscordPlugin extends ButtonPlugin {
private void handleReady(List<GuildCreateEvent> event) {
try {
mainServer = mainServer().get().orElse(null); //Shouldn't change afterwards
getCommand2MC().registerCommand(new DiscordMCCommand()); //Register so that the reset command works
if (mainServer == null) {
if (event.size() == 0) {
getLogger().severe("Main server not found! Invite the bot and do /discord reset");
dc.getApplicationInfo().subscribe(info -> {
getLogger().severe("Click here: https://discordapp.com/oauth2/authorize?client_id=" + info.getId().asString() + "&scope=bot&permissions=268509264");
});
saveConfig(); //Put default there
return; //We should have all guilds by now, no need to retry
}
@ -200,7 +204,6 @@ public class DiscordPlugin extends ButtonPlugin {
CommonListeners.register(dc.getEventDispatcher());
TBMCCoreAPI.RegisterEventsForExceptions(new MCListener(), this);
getCommand2MC().registerCommand(new DiscordMCCommand());
TBMCCoreAPI.RegisterUserClass(DiscordPlayer.class);
ChromaGamerBase.addConverter(sender -> Optional.ofNullable(sender instanceof DiscordSenderBase
? ((DiscordSenderBase) sender).getChromaUser() : null));

View file

@ -31,7 +31,7 @@ import java.util.stream.Collectors;
"Use the ID (command) of the channel, for example `g` for the global chat.", //
"To remove a connection use @ChromaBot channelcon remove in the channel.", //
"Mentioning the bot is needed in this case because the / prefix only works in #bot.", //
"Invite link: <https://discordapp.com/oauth2/authorize?client_id=226443037893591041&scope=bot&permissions=268509264>" //
"Invite link: <Unknown>" //
})
@RequiredArgsConstructor
public class ChannelconCommand extends ICommand2DC {
@ -155,7 +155,7 @@ public class ChannelconCommand extends ICommand2DC {
"Use the ID (command) of the channel, for example `g` for the global chat.", //
"To remove a connection use @ChromaBot channelcon remove in the channel.", //
"Mentioning the bot is needed in this case because the " + DiscordPlugin.getPrefix() + " prefix only works in " + DPUtils.botmention() + ".", //
"Invite link: <https://discordapp.com/oauth2/authorize?client_id=226443037893591041&scope=bot&permissions=268509264>" // TODO: Set correct client ID
"Invite link: <https://discordapp.com/oauth2/authorize?client_id=" + module.clientID + "&scope=bot&permissions=268509264>"
};
}
}

View file

@ -104,10 +104,13 @@ public class MinecraftChatModule extends Component<DiscordPlugin> {
return getConfig().getData("allowPrivateChat", true);
}
String clientID;
@Override
protected void enable() {
if (DPUtils.disableIfConfigErrorRes(this, chatChannel(), chatChannelMono()))
return;
DiscordPlugin.dc.getApplicationInfo().subscribe(info -> clientID = info.getId().asString());
listener = new MCChatListener(this);
TBMCCoreAPI.RegisterEventsForExceptions(listener, getPlugin());
TBMCCoreAPI.RegisterEventsForExceptions(new MCListener(this), getPlugin());//These get undone if restarting/resetting - it will ignore events if disabled

View file

@ -1,8 +1,8 @@
name: Thorpe-Discord
name: Chroma-Discord
main: buttondevteam.discordplugin.DiscordPlugin
version: 1.0
author: NorbiPeti
depend: [ThorpeCore]
depend: [ChromaCore]
commands:
discord:
website: 'https://github.com/TBMCPlugins/DiscordPlugin'