Thread: GE - Discord Announcement

Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 25
  1. #11  
    Registered Member

    Join Date
    Dec 2009
    Posts
    774
    Thanks given
    367
    Thanks received
    455
    Rep Power
    927
    Quote Originally Posted by DylanPage95 View Post
    i'm not quite sure how to smack them all into one message so that it doesn't spam all the offers. like my eg ( .offers dylanpage95) was done in multiple messages (one for each offer)
    if i figure out how to confine it to one message it should save it a little

    PS the most it can send per player is the max GE slots but yes 10 people do it and boom theres 60 messages at once

    - EDIT i just fixed it to send all offers into 1 message i overlooked a very simple misplacement of a for loop and where i was adding new lines

    http://prntscr.com/l3njtd
    Put your discord messages in a queue and handle them every * seconds (don't know discord rules) in a separate thread. Simple as that.
    link removed
    Reply With Quote  
     

  2. #12  
    Krator || Indie Dev

    Jordan Belfort's Avatar
    Join Date
    Dec 2012
    Posts
    1,051
    Thanks given
    535
    Thanks received
    485
    Rep Power
    1172
    Quote Originally Posted by Admiral Slee View Post
    Put your discord messages in a queue and handle them every * seconds (don't know discord rules) in a separate thread. Simple as that.
    Kind of defeats the purpose of real time announcements if you’re delaying them.
    Attached image
    [/CENTER]
    Reply With Quote  
     

  3. #13  
    Rune-Server Affiliate
    Genesis's Avatar
    Join Date
    Sep 2010
    Posts
    4,149
    Thanks given
    1,508
    Thanks received
    1,980
    Rep Power
    4944
    Quote Originally Posted by DylanPage95 View Post
    i'm not quite sure how to smack them all into one message so that it doesn't spam all the offers. like my eg ( .offers dylanpage95) was done in multiple messages (one for each offer)
    if i figure out how to confine it to one message it should save it a little

    PS the most it can send per player is the max GE slots but yes 10 people do it and boom theres 60 messages at once

    - EDIT i just fixed it to send all offers into 1 message i overlooked a very simple misplacement of a for loop and where i was adding new lines

    http://prntscr.com/l3njtd

    Add the messages into a queue, concatenate the messages, and send them in intervals.
    Reply With Quote  
     

  4. #14  
    Registered Member

    Join Date
    Dec 2009
    Posts
    774
    Thanks given
    367
    Thanks received
    455
    Rep Power
    927
    Quote Originally Posted by Jordan Belfort View Post
    Kind of defeats the purpose of real time announcements if you’re delaying them.
    Say that to Discord.
    link removed
    Reply With Quote  
     

  5. #15  
    Krator || Indie Dev

    Jordan Belfort's Avatar
    Join Date
    Dec 2012
    Posts
    1,051
    Thanks given
    535
    Thanks received
    485
    Rep Power
    1172
    Quote Originally Posted by Admiral Slee View Post
    Say that to Discord.
    I’m well aware lol.
    Attached image
    [/CENTER]
    Reply With Quote  
     

  6. #16  
    Its Dylan.... Or Is It


    Join Date
    Jul 2016
    Age
    28
    Posts
    168
    Thanks given
    37
    Thanks received
    11
    Rep Power
    132
    Quote Originally Posted by Nevy View Post
    Looking good! Perhaps you could format the numbers on Discord so they'd look better!
    https://gyazo.com/dd557d1783d4c3ff768580f7b0819553

    is this how you were meaning

    Quote Originally Posted by Genesis View Post
    Add the messages into a queue, concatenate the messages, and send them in intervals.
    Cheers Genesis ill look into that i just did it like

    Code:
                             
                            String message = "\n";
    			for (int i = 0; i <= 7; i++) {
    				Offer offer = GrandExchange.getOffer(World.getPlayer(player.getUsername()), i);
    				if (offer == null || offer.getAmount() - offer.getTotalAmmountSoFar() == 0) {
    					continue;
    				}
    				String suffix = "gp";
    				message += (offer.isBuying() == true ? "Buying: " : "Selling: ") + "- " + offer.getName() + " x" + amt
    						+ " for " + df2.format(tot / divisor) + "" + suffix + "(" + df2.format(each / divisor) + ""
    						+ suffix + " each)\n";
    			}
    i skipped out the eww math parts cause i know its gross af
    ... i have to admit that snippet isnt too flash with the code on here either
    but i used a forloop and added a new line per loop
    Reply With Quote  
     

  7. #17  
    Registered Member
    Join Date
    Jan 2013
    Posts
    610
    Thanks given
    292
    Thanks received
    120
    Rep Power
    39
    Quote Originally Posted by DylanPage95 View Post
    https://gyazo.com/dd557d1783d4c3ff768580f7b0819553

    is this how you were meaning



    Cheers Genesis ill look into that i just did it like

    Code:
                             
                            String message = "\n";
    			for (int i = 0; i <= 7; i++) {
    				Offer offer = GrandExchange.getOffer(World.getPlayer(player.getUsername()), i);
    				if (offer == null || offer.getAmount() - offer.getTotalAmmountSoFar() == 0) {
    					continue;
    				}
    				String suffix = "gp";
    				message += (offer.isBuying() == true ? "Buying: " : "Selling: ") + "- " + offer.getName() + " x" + amt
    						+ " for " + df2.format(tot / divisor) + "" + suffix + "(" + df2.format(each / divisor) + ""
    						+ suffix + " each)\n";
    			}
    i skipped out the eww math parts cause i know its gross af
    ... i have to admit that snippet isnt too flash with the code on here either
    but i used a forloop and added a new line per loop
    Try using StringBuilder instead of String. It does not need to keep re-creating the String object, so it is hugely faster when concatenating lots of words.

    StringBuilder sb = new StringBuilder();
    for (String s : hugeArray) {
    sb.append(s);
    }
    String result = sb.toString();
    Reply With Quote  
     

  8. #18  
    Developer


    Join Date
    Jul 2016
    Posts
    350
    Thanks given
    59
    Thanks received
    33
    Rep Power
    112
    Pretty cool!

    I use an interface in-game to show offers, but this has my intrigued!
    Reply With Quote  
     

  9. Thankful user:


  10. #19  
    Its Dylan.... Or Is It


    Join Date
    Jul 2016
    Age
    28
    Posts
    168
    Thanks given
    37
    Thanks received
    11
    Rep Power
    132
    Quote Originally Posted by Lucifer_ View Post
    Try using StringBuilder instead of String. It does not need to keep re-creating the String object, so it is hugely faster when concatenating lots of words.

    StringBuilder sb = new StringBuilder();
    for (String s : hugeArray) {
    sb.append(s);
    }
    String result = sb.toString();
    so that will basically do the same thing that i put an example of?
    Reply With Quote  
     

  11. #20  
    (Official) Thanksgiver

    Arham's Avatar
    Join Date
    Jan 2013
    Age
    23
    Posts
    3,415
    Thanks given
    7,254
    Thanks received
    1,938
    Rep Power
    3905
    Quote Originally Posted by Jordan Belfort View Post
    Be careful with how many messages you have your bot send. Too many at a time (think of multiple players doing it at once) and your discord bot will lock out on too many requests. Been there lol. But very cool concept. Good luck with future creations.
    At Ataraxia our bot sends messages from the server friends chat by our playerbase of about 50-100. Never had an issue like this. How'd you manage to get a problem? I think you'll be fine Dylan, but still interested in hearing. O.O

    Perhaps it's because our bot uses JDA using .buildAsync() and we .queue() all messages we send. Probably a delay of a few milliseconds or so.

    Quote Originally Posted by DylanPage95 View Post
    so that will basically do the same thing that i put an example of?
    He's telling you that for performance, nothing more.

    Code:
                            StringBuilder messageBuilder = new StringBuilder("\n");
    			for (int i = 0; i <= 7; i++) {
    				Offer offer = GrandExchange.getOffer(World.getPlayer(player.getUsername()), i);
    				if (offer == null || offer.getAmount() - offer.getTotalAmmountSoFar() == 0) {
    					continue;
    				}
    				String suffix = "gp";
    				messageBuilder = messageBuilder.append(offer.isBuying() == true ? "Buying: " : "Selling: ").append("- ").append(offer.getName()).append(" x").append(amt).append(" for ").append(df2.format(tot / divisor)).append(suffix).append("(").append(df2.format(each / divisor)).append(suffix).append(" each)").append("\n");
    			}
    			String message = messageBuilder.toString();
    Attached image
    Attached image
    Quote Originally Posted by MrClassic View Post
    Arham is the official thanker!
    List of my work here!
    Reply With Quote  
     

  12. Thankful users:


Page 2 of 3 FirstFirst 123 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Game Announcement Bot [Discord]
    By Ant0n in forum Show-off
    Replies: 23
    Last Post: 04-09-2018, 03:41 PM
  2. Announcements (explained)
    By Nets8 in forum Tutorials
    Replies: 39
    Last Post: 12-06-2008, 11:59 PM
  3. On-Screen Announcments
    By Alex in forum Tutorials
    Replies: 28
    Last Post: 05-28-2008, 07:13 PM
  4. Summoning Release - To Be Announced
    By Link in forum RS2 Server
    Replies: 122
    Last Post: 05-26-2008, 09:49 AM
  5. Announcement GUI - Zenzie ISN'T Dead!
    By × Se×pert × in forum Tutorials
    Replies: 17
    Last Post: 12-24-2007, 09:29 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •