net.dv8tion.jda.core.entities.Game Java Examples
The following examples show how to use
net.dv8tion.jda.core.entities.Game.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TwitchListener.java From DiscordBlueBot with MIT License | 6 votes |
public void onUserUpdateGame(UserUpdateGameEvent event) { try { if(MainBot.getStreamerList().containsKey(event.getUser().getId()) && !event.getOldGame().getType().equals(Game.GameType.STREAMING) && event.getGuild().getMember(event.getUser()).getGame().getType().equals(Game.GameType.STREAMING)) { List<Guild> serverList = event.getJDA().getGuilds(); for(Guild server : serverList) { if(server.getMembers().contains(event.getUser())) { if(MainBot.getTwitchDisabled().contains(server.getId())) { continue; //function disabled } if(MainBot.getTwitchChannel().containsKey(server.getId())) { event.getJDA().getTextChannelById(MainBot.getTwitchChannel().get(server.getId())).sendMessage(/*server.getPublicRole().getName() + " : " + */event.getUser().getName() + " is now streaming ! Watch live at " + MainBot.getStreamerList().get(event.getUser().getId())).queue(); } else { server.getDefaultChannel().sendMessage(/*server.getPublicRole().getName() + " : " + */event.getUser().getName() + " is now streaming ! Watch live at " + MainBot.getStreamerList().get(event.getUser().getId())).queue(); } } } } } catch (NullPointerException e) { e.printStackTrace(); //The user left streaming } }
Example #2
Source File: Botmessage.java From DiscordBot with Apache License 2.0 | 5 votes |
public static void setSupplyingMessage(JDA jda) { if (!custom) { jda.getGuilds().forEach(g -> g.getMembers().forEach(m -> count())); jda.getPresence().setGame(Game.of("Supplying " + members + " users" + " | -help | v." + STATICS.VERSION)); members = 0; } }
Example #3
Source File: FlareBot.java From FlareBot with MIT License | 5 votes |
public void setStatus(String status) { //TODO: Check if we're actually streaming or not. if (shardManager.getShardsTotal() == 1) { shardManager.setGameProvider(shardId -> Game.streaming(status, "https://www.twitch.tv/discordflarebot")); return; } shardManager.setGameProvider(shardId -> Game.streaming(status + " | Shard: " + shardId + "/" + shardManager.getShardsTotal(), "https://www.twitch.tv/discordflarebot")); }
Example #4
Source File: GameCmd.java From Selfbot with Apache License 2.0 | 5 votes |
@Override protected void execute(String args, MessageReceivedEvent event) { String result; if(args.isEmpty()) { event.getJDA().getPresence().setGame(null); result = "Game cleared."; } else { try { Game game; if(args.startsWith("twitch")) { String[] parts = args.substring(6).trim().split("\\s+",2); args = parts[1]; game = Game.of(args, "http://twitch.tv/"+parts[0]); } else game = Game.of(args); event.getJDA().getPresence().setGame(game); result = "Game set to "+(game.getUrl()==null ? "Playing": "Streaming")+" `"+args+"`. Note that it will appear to everyone else but will not show in your own client."; } catch(Exception e) { result = "Game could not be set to `"+args+"`"; } } tempReply(result, event); }
Example #5
Source File: Botmessage.java From DiscordBot with Apache License 2.0 | 4 votes |
@Override public void action(String[] args, MessageReceivedEvent event) throws ParseException, IOException { if (!Perms.isOwner(event.getAuthor(), event.getTextChannel())) return; custom = true; String messageString = String.join(" ", args); if (messageString.equals("off")) { custom = false; event.getTextChannel().sendMessage(new EmbedBuilder().setColor(Color.GREEN).setDescription("Successfully set botmsg to standard setting!").build()).queue(); return; } event.getJDA().getPresence().setGame(Game.of(messageString + " | -help | v." + STATICS.VERSION)); event.getTextChannel().sendMessage(new EmbedBuilder().setColor(Color.GREEN).setDescription("Successfully set bot message to `" + messageString + "`!").build()).queue(); }