public async Task Help() { var a = new Discord.EmbedBuilder(); a.AddInlineField("/mchelp", "Gets the list of GameOut Minecraft Server commands.").WithColor(25, 25, 112); a.AddInlineField("/adhelp", "Gets the list of bot owner commands."); a.AddInlineField("/reee", "For when autism strikes."); a.AddInlineField("/insult", "For when you wanna insult someone."); a.AddInlineField("/killme", "For when you wanna die."); a.AddInlineField("/8ball", "For when autism strikes."); a.AddInlineField("/tellajoke", "Tells a joke."); a.AddInlineField("/rate + WhatYouWantRatedHere", "Rates the input."); a.AddInlineField("/stats", "Receives bot stats."); a.AddInlineField("/get time", "Gets the current time."); a.AddInlineField("/get date", "Gets the current date."); IDMChannel gencom = await Context.Message.Author.GetOrCreateDMChannelAsync(); await gencom.SendMessageAsync("", false, a); await gencom.CloseAsync(); }
public async Task Me() { EmbedBuilder builder = new EmbedBuilder(); builder.WithTitle($"{Context.User.Username}"); builder.WithDescription("Not implemented"); IDMChannel dmChannel = await Context.Message.Author.GetOrCreateDMChannelAsync(); await dmChannel.SendMessageAsync("", false, builder.Build()); await dmChannel.CloseAsync(); }
public async Task McHelp() { EmbedBuilder b = new EmbedBuilder(); b.WithTitle("GameOut Commands"); b.AddInlineField("/vote", "Provides the voting websites for the GameOut Minecraft server!").WithColor(25, 25, 112); b.AddInlineField("/website", "Get a link for the server's main website!"); b.AddInlineField("/revip", "Shows the ip for the FTB Revelations server!"); IDMChannel augur = await Context.Message.Author.GetOrCreateDMChannelAsync(); await augur.SendMessageAsync("", false, b); await augur.CloseAsync(); }
private async Task UpdateXp(SocketMessage message, IGuildChannel channel) { if (!await _config.XpGainEnabled(channel.Id)) { return; } using IServiceScope scope = _scopeFactory.CreateScope(); var context = scope.ServiceProvider.GetRequiredService <RokiContext>(); GuildConfig guildConfig = await _config.GetGuildConfigAsync(channel.GuildId); UserData data = await context.UserData.AsQueryable().Where(x => x.UserId == message.Author.Id && x.GuildId == channel.GuildId).SingleOrDefaultAsync(); if (data == null) { if (await context.Users.AsNoTracking().AnyAsync(x => x.Id == message.Author.Id)) { data = new UserData(message.Author.Id, channel.GuildId); } else { data = new UserData(message.Author.Id, channel.GuildId) { User = new User(message.Author.Username, message.Author.Discriminator, message.Author.AvatarId) }; } await context.UserData.AddAsync(data); } // temp // these are always false bool doubleXp = data.Xp < 0; bool fastXp = data.Xp < 0; var oldXp = new XpLevel(data.Xp); DateTime now = DateTime.UtcNow; if (fastXp && now - data.LastXpGain >= TimeSpan.FromSeconds(guildConfig.XpFastCooldown)) { data.Xp += doubleXp ? guildConfig.XpPerMessage * 2 : guildConfig.XpPerMessage; } else if (DateTime.UtcNow - data.LastXpGain >= TimeSpan.FromSeconds(guildConfig.XpCooldown)) { data.Xp += doubleXp ? guildConfig.XpPerMessage * 2 : guildConfig.XpPerMessage; } else { return; } data.LastXpGain = now; var newXp = new XpLevel(data.Xp); if (oldXp.Level == newXp.Level) { await context.SaveChangesAsync(); return; } data.LastLevelUp = now; await SendNotification(data, message, newXp.Level).ConfigureAwait(false); List <XpReward> rewards = await context.XpRewards.AsNoTracking().Where(x => x.GuildId == channel.GuildId && x.Level == newXp.Level).ToListAsync(); if (rewards.Count > 0) { var sb = new StringBuilder(); foreach (XpReward reward in rewards) { string[] parsed = reward.Details.Split(';'); if (parsed.Length < 2) { continue; } switch (parsed[0]) { case "currency": { long amount = long.Parse(parsed[1]); await _currency.AddCurrencyAsync(data.UserId, data.GuildId, channel.Id, message.Id, $"#{reward.Id} XP Level {reward.Level} Reward", amount); sb.AppendLine($"+ `{amount:N0}` {guildConfig.CurrencyIcon}"); break; } case "role": { SocketRole role = (channel.Guild as SocketGuild)?.GetRole(ulong.Parse(parsed[1])); if (role == null) { continue; } var guildUser = (IGuildUser)message.Author; await guildUser.AddRoleAsync(role).ConfigureAwait(false); sb.AppendLine(reward.Description); break; } } } IDMChannel dm = await message.Author.GetOrCreateDMChannelAsync().ConfigureAwait(false); try { await dm.EmbedAsync(new EmbedBuilder().WithOkColor() .WithTitle($"Level `{newXp.Level}` Rewards - {channel.Guild.Name}") .WithDescription("Here are your rewards:\n" + sb)) .ConfigureAwait(false); await dm.CloseAsync().ConfigureAwait(false); } catch { // unable to send dm to user // ignored } } await context.SaveChangesAsync(); }