public async Task ShowRanks() { await Context.Channel.TriggerTypingAsync(); _logger.LogInformation("{username}#{discriminator} invoked ranks on {server}/{channel}", Context.User.Username, Context.User.Discriminator, Context.Guild?.Name ?? "DM", Context.Channel.Name); if (await ServerHelper.CheckIfContextIsDM(Context)) { return; } var ranks = await _rankService.GetRanks(Context.Guild); if (ranks.Count == 0) { await ReplyAsync("This server does not yet have any ranks!"); return; } await Context.Channel.TriggerTypingAsync(); string description = "This message lists all available ranks, you can use the name or ID of the rank."; foreach (var rank in ranks) { description += $"\n{rank.Mention} ({rank.Id})"; } await ReplyAsync(description); }
public async Task Server() { await Context.Channel.TriggerTypingAsync(); _logger.LogInformation("{username}#{discriminator} executed server on {server}/{channel}", Context.User.Username, Context.User.Discriminator, Context.Guild?.Name ?? "DM", Context.Channel.Name); if (await ServerHelper.CheckIfContextIsDM(Context)) { return; } var builder = new EmbedBuilder() .WithThumbnailUrl(Context.Guild.IconUrl) .WithDescription("Server information:") .WithTitle($"{Context.Guild.Name} Information") .WithColor(ColorHelper.GetColor(await _servers.GetServer(Context.Guild))) .AddField("Created at", Context.Guild.CreatedAt.ToString("MM/dd/yyyy"), true) .AddField("Member count", (Context.Guild as SocketGuild).MemberCount + " members", true) .AddField("Online users", (Context.Guild as SocketGuild).Users.Where(x => x.Status == UserStatus.Offline).Count() + " members", true) .WithCurrentTimestamp(); var embed = builder.Build(); await ReplyAsync(null, false, embed); }
public async Task InviteCount( [Summary("The user to ban")] SocketGuildUser user = null) { await Context.Channel.TriggerTypingAsync(); if (await ServerHelper.CheckIfContextIsDM(Context)) { return; } if (user == null) { //await ReplyAsync("Please provide a user to lookup!"); user = Context.User as SocketGuildUser; } _logger.LogInformation("{user}#{discriminator} invoked invite {user} in {channel} on {server}", Context.User.Username, Context.User.Discriminator, user.Username, Context.Channel.Name, Context.Guild?.Name ?? "DM"); var server = await ServerHelper.GetOrAddServer(Context.Guild.Id, _serverRepository); var dbuser = await UserHelper.GetOrAddUser(user, _userRepository); var invite = await _inviteRepository.GetInviteByUser(dbuser.Id, server.Id); if (invite == null) { await ReplyAsync($"This feature is experamental and may have issues.\n{user.Username} has not invited anyone"); return; } await ReplyAsync($"This feature is experamental and may have issues.\n{user.Username} has invited {invite.Count} users"); }
public async Task Status() { await Context.Channel.TriggerTypingAsync(); if (await ServerHelper.CheckIfContextIsDM(Context)) { return; } _logger.LogInformation("{user}#{discriminator} invoked invite status in {channel} on {server}", Context.User.Username, Context.User.Discriminator, Context.Channel.Name, Context.Guild?.Name ?? "DM"); var server = await ServerHelper.GetOrAddServer(Context.Guild.Id, _serverRepository); await ReplyAsync($"This feature is experamental and may have issues.\nInvite tracking is `{(server.TrackInvites ? "Enabled" : "Disabled")}`"); }
public async Task JoinAsync() { await Context.Channel.TriggerTypingAsync(); _logger.LogInformation("{username}#{discriminator} executed join on {server}/{channel}", Context.User.Username, Context.User.Discriminator, Context.Guild?.Name ?? "DM", Context.Channel.Name); if (!CheckIfLavaLinkIsEnabled()) { return; } if (await ServerHelper.CheckIfContextIsDM(Context)) { return; } if (_lavaNode.HasPlayer(Context.Guild)) { await ReplyAsync("I'm already connected to a voice channel!"); return; } var voiceState = Context.User as IVoiceState; if (!await CheckIfUserIsInVoiceChannel(voiceState)) { return; } try { await _lavaNode.JoinAsync(voiceState.VoiceChannel, Context.Channel as ITextChannel); await ReplyAsync($"Joined {voiceState.VoiceChannel.Name}!"); } catch (Exception exception) { await ReplyAsync(exception.Message); } }
public async Task Disable() { await Context.Channel.TriggerTypingAsync(); if (await ServerHelper.CheckIfContextIsDM(Context)) { return; } _logger.LogInformation("{user}#{discriminator} invoked invite disable in {channel} on {server}", Context.User.Username, Context.User.Discriminator, Context.Channel.Name, Context.Guild?.Name ?? "DM"); var server = await ServerHelper.GetOrAddServer(Context.Guild.Id, _serverRepository); server.TrackInvites = false; await _serverRepository.EditAsync(server); await ReplyAsync("This feature is experamental and may have issues.\nInvite tracking disabled"); await _serverService.SendLogsAsync(Context.Guild, "Invite Tracking Disabled", $"{Context.User.Mention} Disabled invite tracking!"); }
public async Task Resume() { await Context.Channel.TriggerTypingAsync(); _logger.LogInformation("{username}#{discriminator} executed resume on {server}/{channel}", Context.User.Username, Context.User.Discriminator, Context.Guild?.Name ?? "DM", Context.Channel.Name); if (!CheckIfLavaLinkIsEnabled()) { return; } if (await ServerHelper.CheckIfContextIsDM(Context)) { return; } var voiceState = Context.User as IVoiceState; if (!await CheckForValidState(voiceState)) { return; } var player = _lavaNode.GetPlayer(Context.Guild); if (player.PlayerState == PlayerState.Playing) { await ReplyAsync("Music is already playing"); return; } await player.ResumeAsync(); await ReplyAsync("Music has resumed!"); }
public async Task Skip() { await Context.Channel.TriggerTypingAsync(); _logger.LogInformation("{username}#{discriminator} executed skip on {server}/{channel}", Context.User.Username, Context.User.Discriminator, Context.Guild?.Name ?? "DM", Context.Channel.Name); if (!CheckIfLavaLinkIsEnabled()) { return; } if (await ServerHelper.CheckIfContextIsDM(Context)) { return; } var voiceState = Context.User as IVoiceState; if (!await CheckForValidState(voiceState)) { return; } var player = _lavaNode.GetPlayer(Context.Guild); if (player.Queue.Count == 0) { await ReplyAsync("There are no more songs in the queue!"); return; } await player.SkipAsync(); await ReplyAsync($"Skipped! Now playing **{player.Track.Title}**"); }
public async Task Image([Summary("The user to show a banner for")] SocketGuildUser user = null) { await Context.Channel.TriggerTypingAsync(); _logger.LogInformation("{username}#{discriminator} executed image on {server}/{channel}", Context.User.Username, Context.User.Discriminator, Context.Guild?.Name ?? "DM", Context.Channel.Name); if (await ServerHelper.CheckIfContextIsDM(Context)) { return; } if (user == null) { user = Context.Message.Author as SocketGuildUser; } var background = await _servers.GetBackground(user.Guild.Id); var memoryStream = await _bannerImageService.CreateImage(user, background); memoryStream.Seek(0, SeekOrigin.Begin); await Context.Channel.SendFileAsync(memoryStream, $"{user.Username}.png"); }
public async Task RegisterTimeZone([Summary("Your IANA or Windows timezone")][Remainder] string timeZone = null) { await Context.Channel.TriggerTypingAsync(); _logger.LogInformation("{username}#{discriminator} executed registertimezone ({timezone}) on {server}/{channel}", Context.User.Username, Context.User.Discriminator, timeZone, Context.Guild?.Name ?? "DM", Context.Channel.Name); if (await ServerHelper.CheckIfContextIsDM(Context)) { return; } if (timeZone == null) { await Context.Channel.SendEmbedAsync("Provide a Time Zone", "Please provide a valid windows or IANA timezone.", ColorHelper.GetColor(await _serverService.GetServer(Context.Guild))); return; } if (!TryParseTimeZone(timeZone, out TimeZoneInfo timeZoneInfo)) { await Context.Channel.SendEmbedAsync("Invalid Time Zone", "Please provide a valid windows or IANA timezone.", ColorHelper.GetColor(await _serverService.GetServer(Context.Guild))); } else { var user = await _userRepository.GetByUserId(Context.User.Id); if (user == null) { await _userRepository.AddAsync(new User { UserId = Context.User.Id, UserName = Context.User.Username }); user = await _userRepository.GetByUserId(Context.User.Id); } var userTimeZone = await _userTimeZones.GetByUserID(Context.User.Id); if (userTimeZone == null) { if (user == null) { await _userRepository.AddAsync(new User { UserId = Context.User.Id, UserName = Context.User.Username }); } var userTz = new UserTimeZone { UserId = user.Id, TimeZone = timeZone, }; await _userTimeZones.AddAsync(userTz); await Context.Channel.SendEmbedAsync("Succesfully Registered", $"Successfully registered your time zone: `{timeZoneInfo.DisplayName}`", ColorHelper.GetColor(await _serverService.GetServer(Context.Guild))); } else { userTimeZone.TimeZone = timeZone; await _userTimeZones.EditAsync(userTimeZone); await Context.Channel.SendEmbedAsync("Succesfully Updated", $"Successfully updated your time zone: `{timeZoneInfo.DisplayName}`", ColorHelper.GetColor(await _serverService.GetServer(Context.Guild))); } } }
public async Task PlayAsync([Remainder] string query) { await Context.Channel.TriggerTypingAsync(); _logger.LogInformation("{username}#{discriminator} executed play ({query}) on {server}/{channel}", Context.User.Username, Context.User.Discriminator, query, Context.Guild?.Name ?? "DM", Context.Channel.Name); if (!CheckIfLavaLinkIsEnabled()) { return; } if (await ServerHelper.CheckIfContextIsDM(Context)) { return; } if (string.IsNullOrWhiteSpace(query)) { await ReplyAsync("Please provide search terms."); return; } if (!_lavaNode.HasPlayer(Context.Guild)) { await ReplyAsync("I'm not connected to a voice channel."); await ReplyAsync("Joining you ;-)"); await JoinAsync(); } //var searchResponse = await _lavaNode.SearchAsync(query); var searchResponse = await _lavaNode.SearchYouTubeAsync(query); if (searchResponse.LoadStatus == LoadStatus.LoadFailed || searchResponse.LoadStatus == LoadStatus.NoMatches) { await ReplyAsync($"I wasn't able to find anything for `{query}`."); return; } var player = _lavaNode.GetPlayer(Context.Guild); if (player.PlayerState == PlayerState.Playing || player.PlayerState == PlayerState.Paused) { if (!string.IsNullOrWhiteSpace(searchResponse.Playlist.Name)) { foreach (var track in searchResponse.Tracks) { player.Queue.Enqueue(track); } await ReplyAsync($"Enqueued {searchResponse.Tracks.Count} tracks."); } else { var track = searchResponse.Tracks[0]; player.Queue.Enqueue(track); await ReplyAsync($"Enqueued: {track.Title}"); } } else { var track = searchResponse.Tracks[0]; // First result, maybe a random one? if (!string.IsNullOrWhiteSpace(searchResponse.Playlist.Name)) // Play a playlist, maybe make this an option? { for (var i = 0; i < searchResponse.Tracks.Count; i++) { if (i == 0) { await player.PlayAsync(track); await ReplyAsync($"Now Playing: {track.Title}"); } else { player.Queue.Enqueue(searchResponse.Tracks[i]); } } await ReplyAsync($"Enqueued {searchResponse.Tracks.Count} tracks."); } else { await player.PlayAsync(track); await ReplyAsync($"Now Playing: {track.Title}"); } } }