summaryrefslogtreecommitdiff
path: root/src/main/java/de/romjaki/selfbot/Util.java
blob: 67a106b942679fac6f9994afb2cf0433aba3c25b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package de.romjaki.selfbot;

import net.dv8tion.jda.core.entities.TextChannel;

/**
 * Created by RGR on 19.05.2017.
 */
public class Util {
    private Util() {
        Util.singleton(Util.class);
    }

    public static void singleton(Class<?> clazz) {
        throw new Error("No " + clazz.toGenericString() + " instances for you!");
    }

    public static boolean isBotChannel(TextChannel channel) {
        return channel.getName().toLowerCase().contains("bot");
    }


    public static String escape(String join) {
        return join.replace("\\", "\\\\").replace("\"", "\\\"").replace("\n", "\\n").replace("\t", "\\t");
    }

    public static int clamp(int min, int max, int val) {
        return val < min ? min : (Math.min(val, max));
    }
}