/// <summary> /// This method asynchronously sends a message to the quote approval chat channel. /// </summary> /// <returns></returns> private async Task SendQuoteForApprovalAsync(SocketCommandContext context, SocketUser caller, string QuoteContents, int QuoteID) { SocketTextChannel chan = context.Guild.GetTextChannel(ulong.Parse(BotTools.GetSettingString(BotTools.ConfigurationEntries.QuoteReportChannelID))); var Caller = caller as SocketGuildUser; //IEmote confirmEmote = caller.Guild.GetEmoteAsync() Emote confirmEmote = Emote.Parse("<:qbotDENY:858130936376590407>"); Emote declineEmote = Emote.Parse("<:qbotAPPROVE:858130946985689088>"); Emote ChonkboiL = Emote.Parse("<:qbotBUFFER:858131961939361834>"); Emote ChonkboiR = Emote.Parse("<:qbotBUFFERER:858131975323779153>"); Emote TFC = Emote.Parse("<:TFC:297934728470855681>"); var sent = await chan.SendMessageAsync($"__Quote Add Request__\n" + $"**Requestor**: {Caller.Nickname} ({Caller.Username} - {Caller.Id})\n" + $"**Quote**: {QuoteContents}"); await sent.AddReactionAsync(confirmEmote); await sent.AddReactionAsync(ChonkboiL); await sent.AddReactionAsync(ChonkboiR); await sent.AddReactionAsync(declineEmote); discordclient = context.Client; context.Client.ReactionAdded += ListenForQuoteApproval; }
public async Task MainAsync() { await SetupDirectories(); using (var services = ConfigureServices()) { var client = services.GetRequiredService <DiscordSocketClient>(); var config = new DiscordSocketConfig { AlwaysDownloadUsers = true, MessageCacheSize = 200 }; _discord = client; client.Log += LogAsync; services.GetRequiredService <CommandService>().Log += LogAsync; client.UserJoined += LogJoin; client.UserLeft += LogLeave; Modules.LookupModule.InitialCache(); //Token up await client.LoginAsync(TokenType.Bot, BotTools.GetSettingString(BotTools.ConfigurationEntries.BotToken)); await client.StartAsync(); //await services.GetRequiredService<ServerGuardService>().InitializeAsync(); await services.GetRequiredService <CommandHandlingService>().InitializeAsync(); await Task.Delay(-1); } }
[RequireContext(ContextType.Guild)] //Cannot be requested via DM. public async Task GiveHamachiAsync() { //Log the caller. string LogEntry = $"{DateTime.Now.ToString()} requested by {Context.User.Id} - {Context.User.Username}"; var ReportChannel = Context.Guild.GetTextChannel(BotTools.GetReportingChannelUlong()); var Requestor = Context.User as SocketGuildUser; var caller = Context.User as IGuildUser; //Check the Netbattler Role. if (caller.RoleIds.Contains(RoleModule.GetRole("Netbattler", Context.Guild).Id)) { //Check to see if the user can accept DMs. try { string HamachiServer = BotTools.GetSettingString(BotTools.ConfigurationEntries.HamachiServer); string HamachiPass = BotTools.GetSettingString(BotTools.ConfigurationEntries.HamachiPassword); await Context.User.SendMessageAsync($"**N1 Grand Prix Hamachi Server**\n```\nServer: {HamachiServer}\nPassword: {HamachiPass}\n```\n\nPlease ensure that your PC name on Hamachi matches your Nickname on the N1GP Discord to help make matchmaking easier.\n\n**DO NOT provide the N1 Grand Prix Hamachi server credentials to anyone outside the N1GP.**"); await ReportChannel.SendMessageAsync("", embed : EmbedTool.UserHamachiRequest(Requestor)); await ReplyAsync("You have e-mail."); } catch (Exception) { await ReplyAsync("You currently have DMs disabled. Please enable DMs from users on the server to obtain the Hamachi credentials."); throw; } } else { await ReplyAsync("You are not authorized to obtain Hamachi credentials. Use `!license` before attempting to use this command."); } }
[RequireContext(ContextType.Guild)] //Cannot be requested via DM. public async Task GiveRadminAsync() { //Log the caller. string LogEntry = $"{DateTime.Now.ToString()} requested by {Context.User.Id} - {Context.User.Username}"; var ReportChannel = Context.Guild.GetTextChannel(BotTools.GetReportingChannelUlong()); var Requestor = Context.User as SocketGuildUser; var caller = Context.User as IGuildUser; //Check the Netbattler Role. if (caller.RoleIds.Contains(RoleModule.GetRole("Netbattler", Context.Guild).Id)) { //Check to see if the user can accept DMs. try { //Pivoting this to a complete message rather than string RadminServer = BotTools.GetSettingString(BotTools.ConfigurationEntries.RadminCredentialString); await Context.User.SendMessageAsync(RadminServer); //Updated this to, instead of using a template, use a moderator-specified string in its entirety. -MMX 6/18/2021 await ReportChannel.SendMessageAsync("", embed : EmbedTool.UserRadminRequest(Requestor)); await ReplyAsync("You have e-mail."); } catch (Exception) { await ReplyAsync("You currently have DMs disabled. Please enable DMs from users on the server to obtain the Radmin credentials."); throw; } } else { await ReplyAsync("You are not authorized to obtain Radmin credentials. Use `!license` before attempting to use this command."); } }
/// <summary> /// To be called from the bot's initialization, this caches the ChipLibrary JSON. /// </summary> public static void InitialCache() { ChipLibrary = JsonConvert.DeserializeObject <List <Chip> >(File.ReadAllText(BotTools.GetSettingString(BotTools.ConfigurationEntries.ChipLibraryFileLocation))); Console.WriteLine("Chip Library Initialized."); }