Beispiel #1
0
        public async Task RoleUnSetAsync(params SocketRole[] roles)
        {
            ulong     name = Context.Guild.Id;
            GuildData data;

            if (!GuildManager.CheckGuildData(name))
            {
                await ReplyAsync("No GuildData for this Guild!");

                return;
            }
            else
            {
                data = GuildManager.GetGuildData(name).Result;
            }

            foreach (SocketRole role in roles)
            {
                if (data.AssignableRoles.Contains(role.Id))
                {
                    data.AssignableRoles.Remove(role.Id);
                    await ReplyAsync($"Unset Role {role.Name} from self-apply!");
                }
            }
            await GuildManager.SetGuildData(data);
        }
Beispiel #2
0
        private async Task _client_MessagesBulkDeleted(System.Collections.Generic.IReadOnlyCollection <Cacheable <IMessage, ulong> > messages, ISocketMessageChannel channel)
        {
            ulong         guildID    = ((SocketTextChannel)channel).Guild.Id;
            StringBuilder fieldValue = new StringBuilder();

            foreach (Cacheable <IMessage, ulong> cached in messages)
            {
                fieldValue.Append(cached.Id + ", ");
            }

            var origField = new EmbedFieldBuilder()
                            .WithName(messages.Count + " Messages Deleted")
                            .WithValue(fieldValue.ToString());
            var footer = new EmbedFooterBuilder()
                         .WithIconUrl(_client.CurrentUser.GetAvatarUrl())
                         .WithText("ArbitiesLog");
            var embed = new EmbedBuilder()
                        .AddField(origField)
                        .WithFooter(footer)
                        .WithColor(Color.Red)
                        .Build();
            GuildData guildData = await GuildManager.GetGuildData(guildID);

            await((SocketTextChannel)_client.GetChannel(guildData.LogChannel)).SendMessageAsync(embed: embed);
        }
Beispiel #3
0
        private async Task _client_UserJoined(SocketGuildUser user)
        {
            ulong      guildID = user.Guild.Id;
            LogMessage msg     = new LogMessage(LogSeverity.Info, "EventLogger", $"User {user.Id} Joined Guild {guildID}!");

            Log(msg);

            var      creationTime = user.CreatedAt.UtcDateTime;
            TimeSpan timeExisted  = DateTimeOffset.UtcNow - creationTime;
            var      origField    = new EmbedFieldBuilder()
                                    .WithName("New User Joined")
                                    .WithValue(user.Username);
            var timeField = new EmbedFieldBuilder()
                            .WithName("Account Age")
                            .WithValue(timeExisted.ToString());
            var footer = new EmbedFooterBuilder()
                         .WithIconUrl(_client.CurrentUser.GetAvatarUrl())
                         .WithText("ArbitiesLog");
            var embed = new EmbedBuilder()
                        .WithImageUrl(user.GetAvatarUrl(ImageFormat.Auto, 512))
                        .AddField(origField)
                        .AddField(timeField)
                        .WithFooter(footer)
                        .WithColor(Color.Green)
                        .Build();
            GuildData guildData = await GuildManager.GetGuildData(guildID);

            await((SocketTextChannel)_client.GetChannel(guildData.LogChannel)).SendMessageAsync(embed: embed);
        }
Beispiel #4
0
        private async Task _client_GuildMemberUpdated(SocketUser arg1, SocketUser arg2)
        {
            ulong      guildID = ((SocketGuildUser)arg1).Guild.Id;
            LogMessage msg     = new LogMessage(LogSeverity.Info, "EventLogger", $"User {arg1.Id} in Guild {guildID} Updated!");

            Log(msg);
            SocketGuildUser userStart = (SocketGuildUser)arg1;
            SocketGuildUser userEnd   = (SocketGuildUser)arg2;

            string        actionTaken = "Should Not Be Seen";
            StringBuilder fieldValue  = new StringBuilder();

            if (userStart.Roles.Count != userEnd.Roles.Count)
            {
                if (userStart.Roles.Count < userEnd.Roles.Count)
                {
                    //Role Added
                    IEnumerable differentRoles = userEnd.Roles.Except(userStart.Roles);
                    actionTaken = "Role(s) Added";
                    foreach (SocketRole role in differentRoles)
                    {
                        fieldValue.Append(role.Name + "\n");
                    }
                }
                else
                {
                    //Role Removed
                    IEnumerable differentRoles = userStart.Roles.Except(userEnd.Roles);
                    actionTaken = "Role(s) Removed";
                    foreach (SocketRole role in differentRoles)
                    {
                        fieldValue.Append(role.Name + "\n");
                    }
                }
            }
            else if (userStart.Nickname != userEnd.Nickname)
            {
                actionTaken = "Nickname Changed";
                fieldValue.Append(userStart.Nickname + " --> " + userEnd.Nickname);
            }

            var origField = new EmbedFieldBuilder()
                            .WithName(actionTaken)
                            .WithValue(fieldValue.ToString());
            var footer = new EmbedFooterBuilder()
                         .WithIconUrl(_client.CurrentUser.GetAvatarUrl())
                         .WithText("ArbitiesLog");
            var embed = new EmbedBuilder()
                        .WithImageUrl(userStart.GetAvatarUrl(ImageFormat.Auto, 512))
                        .AddField(origField)
                        .WithFooter(footer)
                        .WithColor(Color.Gold)
                        .Build();
            GuildData guildData = await GuildManager.GetGuildData(guildID);

            await((SocketTextChannel)_client.GetChannel(guildData.LogChannel)).SendMessageAsync(embed: embed);
        }
Beispiel #5
0
        public async Task SetLogAsync(SocketChannel channel)
        {
            ulong chanID = channel.Id;

            if (GuildManager.CheckGuildData(Context.Guild.Id))
            {
                GuildData data = await GuildManager.GetGuildData(Context.Guild.Id);

                data.LogChannel = chanID;
                await GuildManager.SetGuildData(data);
            }
            else
            {
                GuildData data = new GuildData
                {
                    GuildID    = Context.Guild.Id,
                    LogChannel = chanID
                };
                await GuildManager.SetGuildData(data);
            }
        }
Beispiel #6
0
        private async Task _client_UserLeft(SocketGuildUser user)
        {
            ulong      guildID = user.Guild.Id;
            LogMessage msg     = new LogMessage(LogSeverity.Info, "EventLogger", $"User {user.Id} Left Guild {guildID}!");

            Log(msg);

            var origField = new EmbedFieldBuilder()
                            .WithName("User Left")
                            .WithValue(user.Username);
            var footer = new EmbedFooterBuilder()
                         .WithIconUrl(_client.CurrentUser.GetAvatarUrl())
                         .WithText("ArbitiesLog");
            var embed = new EmbedBuilder()
                        .WithImageUrl(user.GetAvatarUrl(ImageFormat.Auto, 512))
                        .AddField(origField)
                        .WithFooter(footer)
                        .WithColor(Color.Red)
                        .Build();
            GuildData guildData = await GuildManager.GetGuildData(guildID);

            await((SocketTextChannel)_client.GetChannel(guildData.LogChannel)).SendMessageAsync(embed: embed);
        }
Beispiel #7
0
        public async Task RoleAsync(SocketRole role)
        {
            ulong        servID    = Context.Guild.Id;
            List <ulong> userRoles = new List <ulong>();

            foreach (SocketRole usrRole in Context.Guild.GetUser(Context.User.Id).Roles)
            {
                userRoles.Add(usrRole.Id);
            }


            if (GuildManager.CheckGuildData(servID))
            {
                GuildData data;
                data = GuildManager.GetGuildData(servID).Result;
                foreach (ulong roleID in data.AssignableRoles)
                {
                    if (roleID == role.Id)
                    {
                        if (userRoles.Contains(role.Id))
                        {
                            await Context.Guild.GetUser(Context.User.Id).RemoveRoleAsync(role);
                            await ReplyAsync($"Removed {role.Name}!");
                        }
                        else
                        {
                            await Context.Guild.GetUser(Context.User.Id).AddRoleAsync(role);
                            await ReplyAsync($"Added {role.Name}!");
                        }
                    }
                }
            }
            else
            {
                await ReplyAsync("No GuildData for this Guild!");
            }
        }