Skip to content

Instantly share code, notes, and snippets.

@tech6
Created June 8, 2017 16:44
Show Gist options
  • Save tech6/9bff3346571712285497691d98473e53 to your computer and use it in GitHub Desktop.
Save tech6/9bff3346571712285497691d98473e53 to your computer and use it in GitHub Desktop.
package Discord.Core;
import DiscordBotCode.Main.ChatUtils;
import Startup.BotCore;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit;
public class Announcements
{
public static void init(){
addAnnouncement(TimeUnit.MINUTES.convert(3, TimeUnit.HOURS), "Vote for WoWGasm and earn tokens that can be used for in-game rewards! Login and vote here: http://wowgasm-reloaded.org/index.php?p=vote","general");
// addAnnouncement(TimeUnit.MINUTES.convert(6, TimeUnit.HOURS), "```Just a friendly reminder that jokes and memes referring to rape or suicide are not allowed here in any shape, form, or context, no matter who it is directed at or whether it's a general statement. ♥```","main-chat");
// addAnnouncement(TimeUnit.MINUTES.convert(2, TimeUnit.HOURS),"<@&299132024592138240> If you are 18+ and wish to have full access to Room 34, type, ``I agree`` either here in this chat or in your DM with Gigawhore.","preface");
}
private static long delay = TimeUnit.MILLISECONDS.convert(5, TimeUnit.MINUTES);
private static long curDelay = 0;
public static void addAnnouncement( long everyXmin, String text,String channel){
curDelay += delay;
long time = TimeUnit.MILLISECONDS.convert(everyXmin, TimeUnit.MINUTES);
BotCore.timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run()
{
if(!MainDiscordBot.silentMode) {
ChatUtils.sendMessage(ChannelUtils.getChannel(channel), text);
}
}
}, 0, time);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment