public async Task KickCommand([RequireHierarchy] IUser user, string reason = "") { // Create reason string _reason; if (reason == "") { _reason = $"{Context.User.Username}#{Context.User.Discriminator} kicked this user. No reason provided."; } else { _reason = $"{Context.User.Username}#{Context.User.Discriminator} kicked this user for: {reason}"; } await(user as IGuildUser).KickAsync(_reason); if (reason == "") { await Respond.SendResponse(Context, $"Kicked user **{user.Username}#{user.Discriminator}**."); } else { await Respond.SendResponse(Context, $"Kicked user **{user.Username}#{user.Discriminator}** for `{reason}`."); } }
public async Task ChangeStatusCommand(int status) { if (status < 1 || status > 4) { await Respond.SendResponse(Context, "Status can only be between **1-4**!"); return; } BotConfigService.SetDefaultStatus(status); switch (status) { case 1: await Context.Client.SetStatusAsync(UserStatus.Online); break; case 2: await Context.Client.SetStatusAsync(UserStatus.Idle); break; case 3: await Context.Client.SetStatusAsync(UserStatus.DoNotDisturb); break; case 4: await Context.Client.SetStatusAsync(UserStatus.Offline); break; } }
public static async Task PardonUser(SocketCommandContext Context, ulong id) { bool _didPardon = false; // Do native unban var _bans = await Context.Guild.GetBansAsync(); if (_bans.Any(s => s.User.Id == id)) { await Context.Guild.RemoveBanAsync(_bans.First(s => s.User.Id == id).User); _didPardon = true; } // Pardon forceban, if one exists var _config = Database.GetRecord<GuildConfig>(s => s.ID == Context.Guild.Id); if (_config.Forcebans.Any(s => s == id)) { _config.Forcebans.Remove(id); Database.UpsertRecord(_config); _didPardon = true; } if (_didPardon) { await Respond.SendResponse(Context, $"User with ID `{id}` has been pardoned."); } else { await Respond.SendResponse(Context, $"User with ID `{id}` has not been banned or forcebanned."); } }
public static async Task EditTag(SocketCommandContext Context, string tag, string newMessage) { var _tag = Database.GetRecord <Tag>(s => s.Stats.Alias == tag); if (_tag == null) { await Respond.SendResponse(Context, "That tag does not exist."); return; } if (_tag.CreatedBy != $"{Context.User.Username}#{Context.User.Discriminator}" || !(Context.User as IGuildUser).GuildPermissions.Administrator) { await Respond.SendResponse(Context, "You do not have the required permissions to edit this tag."); return; } _tag.Message = newMessage; Database.UpsertRecord(_tag); await Respond.SendResponse(Context, "Tag changed successfully."); }
public async Task BanCommand([RequireHierarchy] IUser user, string reason = "") { // Create reason string _reason; if (reason == "") { _reason = $"{Context.User.Username}#{Context.User.Discriminator} banned this user. No reason provided."; } else { _reason = $"{Context.User.Username}#{Context.User.Discriminator} banned this user for: {reason}"; } await Context.Guild.AddBanAsync(user, reason : _reason); if (reason == "") { await Respond.SendResponse(Context, $"Banned user **{user.Username}#{user.Discriminator}**."); } else { await Respond.SendResponse(Context, $"Banned user **{user.Username}#{user.Discriminator}** for reason: `{reason}`."); } }
public static async Task Play(SocketCommandContext Context, string song) { if ((Context.User as IVoiceState).VoiceChannel == null) { await Respond.SendResponse(Context, "You are not in a voice channel!"); return; } var _client = Clients.FirstOrDefault(s => s.GuildId == Context.Guild.Id); if (_client == null) { var _new = new AudioClientWrapper(Context); await _new.AddToQueue(Context, song); Clients.Add(_new); } else { await _client.AddToQueue(Context, song); } await Context.Message.DeleteAsync(); }
public static async Task DeleteTag(SocketCommandContext Context, string tag) { tag = tag.ToLower(); var _tag = Database.GetRecord <Tag>(s => s.Stats.Alias == tag); if (_tag == null) { await Respond.SendResponse(Context, "That tag does not exist."); return; } if (_tag.CreatedBy != $"{Context.User.Username}#{Context.User.Discriminator}" || !(Context.User as IGuildUser).GuildPermissions.Administrator) { await Respond.SendResponse(Context, "You do not have the required permissions to edit this tag."); return; } Database.DeleteRecord <Tag>(s => s.Stats.Alias == tag && s.Stats.GuildId == Context.Guild.Id); await Respond.SendResponse(Context, "Tag deleted successfully."); }
public static async Task Unmute(SocketCommandContext Context, ulong id) { var _role = await GetOrCreateMutedRoleAsync(Context.Guild); var _user = Context.Guild.GetUser(id); if (_user == null) { await Respond.SendResponse(Context, $"I could not find a user with the ID: `{id}`"); return; } if (!_user.Roles.Any(s => s.Id == _role.Id)) { await Respond.SendResponse(Context, $"{_user.Username}#{_user.Discriminator} is already unmuted!"); return; } await _user.RemoveRoleAsync(_role); await Respond.SendResponse(Context, $"Unmuted {_user.Username}#{_user.Discriminator}."); RemoveMute(_user); }
public static async Task Magic8Service(SocketCommandContext Context) { var _answers = Get8BallAnswers(); var _r = new Random().Next(0, _answers.Length); await Respond.SendResponse(Context, _answers[_r]); }
public async Task RestardCommand() { await Respond.SendResponse(Context, ":thumbsup:"); Process.Start(Assembly.GetExecutingAssembly().Location); Environment.Exit(1); }
public static async Task Mute(SocketCommandContext Context, IGuildUser user) { await user.AddRoleAsync(await GetOrCreateMutedRoleAsync(Context.Guild)); await Respond.SendResponse(Context, $"Muted user **{user.Username}#{user.Discriminator}**."); AddMute(user); }
public static async Task Remove(SocketCommandContext Context, int index) { if (!Clients.Any(s => s.GuildId == Context.Guild.Id)) { await Respond.SendResponse(Context, "No player is connected to this guild."); return; } await Clients.FirstOrDefault(s => s.GuildId == Context.Guild.Id).Remove(Context, index); }
public static async Task ForcebanUser(SocketCommandContext Context, ulong id) { var _config = Database.GetRecord<GuildConfig>(s => s.ID == Context.Guild.Id); _config.Forcebans.Add(id); Database.UpsertRecord(_config); await Respond.SendResponse(Context, $"User with ID `{id}` has been forcebanned from this guild."); }
public async Task ResetGuildConfigCommand() { foreach (var guild in Context.Client.Guilds) { Database.DeleteRecord <GuildConfig>(s => s.ID == guild.Id); Database.CreateDefaultGuildConfig(Context.Guild, out _); } await Respond.SendResponse(Context, "Restored all guild configurations to default."); }
public static async Task Skip(SocketCommandContext Context) { var _client = Clients.FirstOrDefault(s => s.GuildId == Context.Guild.Id); if (_client == null) { await Respond.SendResponse(Context, "No player is connected to this guild."); return; } _client.Skip(); }
public async Task GameHoursCommand([Remainder] string game) { var _hours = LeaderboardService.GetGameHours(Context.Guild.Id, Context.User.Id, game); if (_hours == null) { await Respond.SendResponse(Context, $"You have no recorded hours for: `{game}`."); return; } await Respond.SendResponse(Context, $"You have `{Math.Round(_hours.Time.TotalHours, 2)}` hours on *{game}*."); }
public static async Task ClearCommandService(SocketCommandContext Context, int count, ulong userId) { if (count > 100) { await Respond.SendResponse(Context, $"Use a number less than 100."); return; } AddToTimedList(Context.Channel.Id); var _msgs = Context.Channel.GetCachedMessages(100).Where(s => s.Author.Id == userId); await(Context.Channel as ITextChannel).DeleteMessagesAsync(_msgs); }
public static async Task Mute(SocketCommandContext Context, IGuildUser user, string time) { await user.AddRoleAsync(await GetOrCreateMutedRoleAsync(Context.Guild)) .ConfigureAwait(false); var _time = Parse.Time(time); if (_time.TotalDays == 0) { _time = TimeSpan.FromMinutes(30); } AddMute(user, _time); await Respond.SendResponse(Context, $"Muted user **{user.Username}#{user.Discriminator}** for {time}."); }
public static async Task Mute(SocketCommandContext Context, ulong id) { if (Context.Guild.GetUser(id) == null) { await Respond.SendResponse(Context, $"I could not find a user with the ID: `{id}`."); return; } await Context.Guild.GetUser(id).AddRoleAsync(await GetOrCreateMutedRoleAsync(Context.Guild)). ConfigureAwait(false); await Respond.SendResponse(Context, $"Muted user **{Context.Guild.GetUser(id).Username}#{Context.Guild.GetUser(id).Discriminator}**."); AddMute(Context.Guild.GetUser(id)); }
public async Task LogCommand() { var _config = Database.GetRecord <GuildConfig>(s => s.ID == Context.Guild.Id); if (_config == null) { Database.CreateDefaultGuildConfig(Context.Guild, out _config); } _config.LogChannelID = Context.Channel.Id; _config.Log = !_config.Log; Database.UpsertRecord(_config); await Respond.SendResponse(Context, $"Logging has been **{(_config.Log ? "Enabled" : "Disabled")}** for this channel."); }
public static async Task JoinAudio(SocketCommandContext Context) { // Already in voice channel if (Clients.Any(s => s.GuildId == Context.Guild.Id)) { return; } // Not in a voice channel if ((Context.User as IVoiceState).VoiceChannel == null) { await Respond.SendResponse(Context, "You are not in a voice channel!"); return; } Clients.Add(new AudioClientWrapper(Context)); }
public static async Task Unmute(SocketCommandContext Context, IGuildUser user) { var _role = await GetOrCreateMutedRoleAsync(Context.Guild); if (!user.RoleIds.Contains(_role.Id)) { await Respond.SendResponse(Context, $"{user.Username}#{user.Discriminator} is already unmuted!"); return; } await user.RemoveRoleAsync(_role); await Respond.SendResponse(Context, $"Unmuted {user.Username}#{user.Discriminator}."); RemoveMute(user); }
public static async Task ChangeName(SocketCommandContext Context, string name) { await Respond.SendResponse(Context, $"I am about to change my name to **{name}**. Are you sure you want to continue? (yes/no)"); var _answer = ConfirmationService.instance.AwaitSimpleReply(Context); if (_answer) { await Context.Client.CurrentUser.ModifyAsync(s => s.Username = name); await Respond.SendResponse(Context, $"Changed name to **{name}**."); } else { await Respond.SendResponse(Context, $"Cancelled."); } }
public static async Task SendTag(SocketCommandContext Context, string tag) { tag = tag.ToLower(); var _tag = Database.GetRecord <Tag>(s => s.Stats.Alias == tag && s.Stats.GuildId == Context.Guild.Id); if (_tag == null) { await Respond.SendResponse(Context, $"Tag not found."); return; } _tag.TimesUsed++; Database.UpsertRecord(_tag); await Context.Channel.SendMessageAsync(_tag.Message); }
public static async Task CreateTag(SocketCommandContext Context, string tag, string message) { tag = tag.ToLower(); // Check for keywords List <string> _keywords = new List <string>() { "create", "add", "delete", "edit", }; if (_keywords.Any(s => s.ToLower() == tag)) { await Respond.SendResponse(Context, "That alias is not available, as it's a keyword."); return; } // Check if tag already exists if (Database.GetRecord <Tag>(s => s.Stats.Alias == tag && s.Stats.GuildId == Context.Guild.Id) != null) { await Respond.SendResponse(Context, "A tag already exists for that alias."); return; } var _newTag = new Tag() { Stats = new Tag.TagStats() { GuildId = Context.Guild.Id, Alias = tag }, Message = message, CreatedBy = $"{Context.User.Username}#{Context.User.Discriminator}", CreatedAt = DateTime.UtcNow }; Database.UpsertRecord(_newTag); await Respond.SendResponse(Context, "Tag created."); }
public async Task GetMuteRecordCommand(ulong userId, ulong guildId = 0) { // Get corresponding guild if (guildId == 0) { guildId = Context.Guild.Id; } else { var __guild = Context.Client.GetGuild(guildId); if (__guild == null) { await Respond.SendResponse(Context, $"Could not find guild with ID: `{guildId}`"); return; } } var _record = Database.GetRecord <MuteRecord>(s => s.UserId == userId && s.GuildId == guildId); await Respond.SendResponse(Context, (!(_record == null)).ToString()); }
public async Task ChangeGameCommand(int status, [Remainder] string game) { if (status < 1 || status > 4) { await Respond.SendResponse(Context, "Status can only be between **1-4**!"); return; } BotConfigService.SetDefaultActivity(status, game); switch (status) { case 1: await Context.Client.SetGameAsync(game, type : ActivityType.Playing); break; case 2: await Context.Client.SetGameAsync(game, type : ActivityType.Listening); break; case 3: await Context.Client.SetGameAsync(game, type : ActivityType.Watching); break; case 4: await Context.Client.SetGameAsync(game, "https://www.twitch.tv/", ActivityType.Streaming); break; default: await Respond.SendResponse(Context, "Please limit activity `1-4`."); break; } }
public static async Task TagStats(SocketCommandContext Context, string tag) { tag = tag.ToLower(); var _tag = Database.GetRecord <Tag>(s => s.Stats.Alias == tag); if (_tag == null) { await Respond.SendResponse(Context, "That tag does not exist."); return; } var _embed = new EmbedBuilder() .WithColor(Color.Blue) .WithTitle(tag) .AddField("Created by:", _tag.CreatedBy, true) .AddField("Created on:", _tag.CreatedAt.ToLongDateString(), true) .AddField("Times used:", _tag.TimesUsed) .WithDescription($"**Returns**:\n{_tag.Message}"); await Context.Channel.SendMessageAsync(embed : _embed.Build()); }
public async Task ShutdownCommand() { await Respond.SendResponse(Context, ":thumbsup:"); Environment.Exit(1); }
public async Task ChangePrefixCommand(string newPrefix) { BotConfigService.SetPrefix(newPrefix); await Respond.SendResponse(Context, $"My new prefix is now: `{newPrefix}`!"); }