private async Task Client_UserJoined(SocketGuildUser user) { var age = (DateTime.UtcNow - user.CreatedAt.UtcDateTime); string timespanString; if (age.TotalDays > 1) { timespanString = $"{Math.Round(age.TotalDays, 1)} days"; } else if (age.TotalHours > 1) { timespanString = $"{Math.Round(age.TotalHours, 1)} hours"; } else if (age.TotalMinutes > 1) { timespanString = $"{Math.Round(age.TotalMinutes, 1)} minutes"; } else { timespanString = $"{Math.Round(age.TotalSeconds, 1)} seconds"; } var a = $"<@{user.Id}> joined on {DateTime.Now}\nThis account is {timespanString} old"; await Append(a); if (MuteSystem.IsMuted(user.Id)) { await user.AddRoleAsync(android.MainGuild.GetRole(Server.Roles.Muted)); } await Task.CompletedTask; }
private static async Task ParseAndMute(CommandParameters parameters, bool muted, TimeSpan duration = default) { var relevantUsers = parameters.SocketMessage.MentionedUsers; if (!relevantUsers.Any()) { await parameters.SocketMessage.Channel.SendMessageAsync(DebugResponseConfiguration.Current.NoUserSpecifiedResponse.PickRandom()); return; } foreach (SocketGuildUser user in relevantUsers) { if (muted) { await MuteSystem.Mute(user.Id, parameters.SocketMessage.Channel.Id, duration); } else { await MuteSystem.Unmute(user.Id); } } }
public async Task Consequence(SocketMessage message, Android android) { await message.Channel.SendMessageAsync($"mentioning over {MentionThreshold} users in one message is against the rules\nyou will be muted for {MuteDurationInDays} days"); await MuteSystem.Mute(message.Author.Id, message.Channel.Id, TimeSpan.FromDays(MuteDurationInDays)); }