예제 #1
0
        public async Task ShowAutoRoles()
        {
            await Context.Channel.TriggerTypingAsync();

            _logger.LogInformation("{username}#{discriminator} executed autoroles on {server}/{channel}",
                                   Context.User.Username, Context.User.Discriminator, Context.Guild?.Name ?? "DM", Context.Channel.Name);

            var autoRoles = await _autoRoleService.GetAutoRoles(Context.Guild);

            if (autoRoles == null || !autoRoles.Any())
            {
                await ReplyAsync("This server does not yet have any autoroles!");

                return;
            }

            string description = "This message lists all available autoroles.\n in order to remove and autorole, use the name or ID";

            foreach (var role in autoRoles)
            {
                description += $"\n{role.Mention} ({role.Id})";
            }

            await ReplyAsync(description);
        }
예제 #2
0
        internal static async Task AssignAutoRoles(IAutoRoleService autoRoleService, SocketGuildUser userJoining)
        {
            var roles = await autoRoleService.GetAutoRoles(userJoining.Guild);

            if (!roles.Any())
            {
                Log.Information("AutoRoleHelper: No auto roles to assign to {user} in {server}", userJoining.Username, userJoining.Guild.Name);
                return;
            }

            Log.Information("AutoRoleHelper: Assigning auto roles to {user}", userJoining.Username);
            await userJoining.AddRolesAsync(roles);
        }