public async Task ShowRankEXP(int rank) { try { if (rank <= 0) { throw new ArgumentException("Rank cannot be less than 0"); } var rankedUsers = await GuildUsers.GetRankedGuildUsersAsync(Context.Guild); if (rank > rankedUsers.Count) { throw new ArgumentException("Rank exceeds number of ranked users"); } var target = rankedUsers[rank - 1]; if (target is null) { throw new InvalidOperationException($"User at rank `{rank}` could not be found"); } string imageURL = $"{Global.Config.DashboardURL}/api/servers/{target.Guild.Id}/users/{target.Id}/xp-card"; var stream = await CommandUtils.DownloadData(imageURL); await Context.Channel.SendFileAsync(stream, "server-xp-card.png"); } catch (ArgumentException ex) { await ReplyAsync(EmbedHandler.CreateErrorEmbed(ModuleName, ex.Message)); } }
public static async Task AnnounceUserJoin(SocketGuildUser guildUser) { if (guildUser.IsBot) { return; } var guild = await Guilds.GetAsync(guildUser.Guild); var announce = guild.General.Announce; var embed = new EmbedBuilder(); var socketGuild = guildUser.Guild; var channel = socketGuild.GetTextChannel(announce.Welcomes.Channel) ?? socketGuild.SystemChannel ?? socketGuild.DefaultChannel; string imageURL = $"{Global.Config.DashboardURL}/api/servers/{guildUser.Guild.Id}/users/{guildUser.Id}/welcome"; var stream = await CommandUtils.DownloadData(imageURL); if (!announce.DMNewUsers) { await(channel as ISocketMessageChannel)?.SendFileAsync(stream, "welcome.png"); } else if (announce.DMNewUsers) { await guildUser.SendFileAsync(stream, "welcome.png"); } }
public async Task GlobalProfile(SocketUser target = null) { target ??= Context.User; string imageURL = $"{Global.Config.DashboardURL}/api/users/{target.Id}/xp-card"; var stream = await CommandUtils.DownloadData(imageURL); await Context.Channel.SendFileAsync(stream, "xp-card.png"); }
public async Task ShowEXP(SocketGuildUser target = null) { target ??= Context.User as SocketGuildUser; string imageURL = $"{Global.Config.DashboardURL}/api/servers/{target.Guild.Id}/users/{target.Id}/xp-card"; System.Console.WriteLine(imageURL); var stream = await CommandUtils.DownloadData(imageURL); await Context.Channel.SendFileAsync(stream, "server-xp-card.png"); }
public static async Task AnnounceUserLeft(SocketGuildUser guildUser) { var user = await GuildUsers.GetAsync(guildUser); if (guildUser as SocketUser == Global.Client.CurrentUser || user.Status.IsBanned) { return; } var guild = await Guilds.GetAsync(guildUser.Guild); string imageURL = $"{Global.Config.DashboardURL}/api/servers/{guildUser.Guild.Id}/users/{guildUser.Id}/goodbye"; var stream = await CommandUtils.DownloadData(imageURL); var channel = guildUser.Guild.GetTextChannel(guild.General.Announce.Goodbyes.Channel) ?? guildUser.Guild.SystemChannel ?? guildUser.Guild.DefaultChannel; await(channel as ISocketMessageChannel)?.SendFileAsync(stream, "goodbye.png"); }