Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Discord;
- using Discord.WebSocket;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace DiscordTest
- {
- class Program
- {
- private static SocketGuild server;
- private static SocketTextChannel channel;
- static void Main(string[] args)
- {
- DiscordSocketClient client = new DiscordSocketClient();
- client.Log += OnLog;
- client.GuildAvailable += ServerAvailable;
- client.LoginAsync(Discord.TokenType.User, "ThisIsMyToken").Wait();
- client.StartAsync().Wait();
- Console.WriteLine("Connected: " + client.ConnectionState);
- bool exit = false;
- while(!exit)
- {
- string cmd = Console.ReadLine();
- if(cmd == "/exit")
- {
- Console.WriteLine("Exiting...");
- exit = true;
- }
- else if(channel != null)
- {
- EmbedBuilder embed = new EmbedBuilder();
- embed.Url = "http://ragepluginhook.net/Downloads.aspx";
- embed.ThumbnailUrl = "http://ragepluginhook.net/images/HookLogoSmall.png";
- embed.Title = "The new RagePluginHook version is released!";
- embed.Color = new Color(/*0x70AEFF*/0x20ba0e);
- embed.Description = cmd;
- channel.SendMessageAsync(" ", false, embed).Wait();
- Console.WriteLine("Sent: " + cmd);
- }
- else
- Console.WriteLine("Server or channel not available");
- }
- client.LogoutAsync().Wait();
- }
- private static Task ServerAvailable(SocketGuild arg)
- {
- if(arg.Name.Contains("RAGE"))
- {
- server = arg;
- foreach(SocketTextChannel c in server.TextChannels)
- {
- if(c.Name == "moderation")
- {
- Console.WriteLine("Ready");
- channel = c;
- }
- }
- }
- return null;
- }
- private static Task OnLog(LogMessage arg)
- {
- ConsoleColor defaultColor = Console.ForegroundColor;
- Console.ForegroundColor = GetSeverityColor(arg.Severity);
- Console.Write("[" + arg.Source + '/' + arg.Severity + "] ");
- Console.ForegroundColor = defaultColor;
- Console.WriteLine(arg.Message);
- if(arg.Exception != null)
- Console.WriteLine(arg.Exception);
- return null;
- }
- private static ConsoleColor GetSeverityColor(LogSeverity severity)
- {
- switch(severity)
- {
- case LogSeverity.Critical:
- case LogSeverity.Error:
- return ConsoleColor.Red;
- case LogSeverity.Warning:
- return ConsoleColor.Yellow;
- case LogSeverity.Info:
- return ConsoleColor.White;
- case LogSeverity.Verbose:
- case LogSeverity.Debug:
- return ConsoleColor.DarkGray;
- }
- return ConsoleColor.White;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement