Example #1
0
        public async Task Status(CommandContext ctx, string type, [RemainingText] string status)
        {
            if (!ctx.Channel.IsPrivate)
            {
                await ctx.Channel.DeleteMessageAsync(ctx.Message);
            }

            var authUsers = new ulong[] { 209279906280898562, 135747025000988672, 265096437937864705 };

            if (!authUsers.Any(id => id == ctx.User.Id))
            {
                throw new UnauthorizedUserException("You are not permitted to use this command!");
            }
            else
            {
                if (status.Equals("clear"))
                {
                    var embed = new DiscordEmbedBuilder()
                                .WithAuthor(ctx.Member.DisplayName, null, ctx.Member.AvatarUrl)
                                .WithColor(DiscordColor.SapGreen)
                                .WithDescription("Bot status has been cleared!")
                                .WithFooter("Silk", ctx.Client.CurrentUser.AvatarUrl)
                                .WithTimestamp(DateTime.Now);

                    await ctx.Client.UpdateStatusAsync();

                    await ctx.RespondAsync(embed : embed);
                }

                else
                {
                    if (!Enum.TryParse(typeof(ActivityType), type, true, out var activity))
                    {
                        await Status(ctx, status);

                        return;
                    }
                    else
                    {
                        await ctx.Client.UpdateStatusAsync(new DiscordActivity(status, (ActivityType)activity), idleSince : DateTime.Now);

                        var msg = await ctx.RespondAsync(embed : EmbedHelper.CreateEmbed(ctx, "Status", $"Successfully set status to {status}!"));

                        await Task.Delay(3000);

                        await ctx.Channel.DeleteMessageAsync(msg);
                    }
                }
            }
        }
Example #2
0
 public async Task SetLoggingChannel(CommandContext ctx, DiscordChannel logChannel)
 {
     await ctx.RespondAsync(embed: EmbedHelper.CreateEmbed(ctx, "Log channel set!", $"I'll log actions to {logChannel.Mention}!", DiscordColor.SapGreen));
     var serverConfigExists = !(ServerConfigurationManager.LocalConfiguration.FirstOrDefault(config => config.Key == ctx.Guild.Id).Value is null);
     if (!serverConfigExists) 
     {
         var config = await ServerConfigurationManager.Instance.GenerateConfigurationFromIdAsync(ctx.Guild.Id);
         config.LoggingChannel = logChannel.Id;
     }
     else 
     {
         ServerConfigurationManager.LocalConfiguration.First(config => config.Value.Guild == ctx.Guild.Id).Value.LoggingChannel = logChannel.Id;
     }
         
 }
Example #3
0
        public async Task UnBan(CommandContext ctx, DiscordUser user, [RemainingText] string reason = "No reason given.")
        {
            if ((await ctx.Guild.GetBansAsync()).Any(ban => ban.User.Id == user.Id))
            {
                await user.UnbanAsync(ctx.Guild, reason);

                var embed = new DiscordEmbedBuilder(EmbedHelper.CreateEmbed(ctx, "", $"Unanned `{user.Username}#{user.Discriminator} ({user.Id})`! ")).AddField("Reason:", reason);

                await ctx.RespondAsync(embed : embed);
            }
            else
            {
                var embed = new DiscordEmbedBuilder(EmbedHelper.CreateEmbed(ctx, "", $"{user.Mention} is not banned!")).WithColor(new DiscordColor("#d11515"));
                await ctx.RespondAsync(embed : embed);
            }
        }