mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-05-06 05:56:29 +03:00
fixed a few bugs in settings + code style consistency with string comparison
This commit is contained in:
parent
a06376443f
commit
2493e317d0
8 changed files with 72 additions and 51 deletions
|
@ -18,7 +18,7 @@ public class MuteCommand : Command {
|
|||
Warn(Messages.DurationParseFailed);
|
||||
reason = Utils.JoinString(ref args, 1);
|
||||
|
||||
if (reason == "") {
|
||||
if (reason is "") {
|
||||
Error(Messages.ReasonRequired, false);
|
||||
return;
|
||||
}
|
||||
|
@ -53,13 +53,13 @@ public class MuteCommand : Command {
|
|||
var author = (SocketGuildUser)context.User;
|
||||
|
||||
var permissionCheckResponse = CommandHandler.HasPermission(ref author, GuildPermission.ModerateMembers);
|
||||
if (permissionCheckResponse != "") {
|
||||
if (permissionCheckResponse is not "") {
|
||||
Error(permissionCheckResponse, true);
|
||||
return;
|
||||
}
|
||||
|
||||
var interactionCheckResponse = CommandHandler.CanInteract(ref author, ref toMute);
|
||||
if (interactionCheckResponse != "") {
|
||||
if (interactionCheckResponse is not "") {
|
||||
Error(interactionCheckResponse, true);
|
||||
return;
|
||||
}
|
||||
|
@ -79,14 +79,15 @@ public class MuteCommand : Command {
|
|||
var hasDuration = duration.TotalSeconds > 0;
|
||||
|
||||
if (role != null) {
|
||||
if (config["RemoveRolesOnMute"] == "true") {
|
||||
if (config["RemoveRolesOnMute"] is "true") {
|
||||
var rolesRemoved = new List<ulong>();
|
||||
foreach (var userRole in toMute.Roles)
|
||||
try {
|
||||
if (userRole == guild.EveryoneRole || userRole == role) continue;
|
||||
await toMute.RemoveRoleAsync(role);
|
||||
rolesRemoved.Add(userRole.Id);
|
||||
} catch (HttpException e) {
|
||||
}
|
||||
catch (HttpException e) {
|
||||
Warn(string.Format(Messages.RoleRemovalFailed, $"<@&{userRole}>", Utils.Wrap(e.Reason)));
|
||||
}
|
||||
|
||||
|
@ -104,7 +105,8 @@ public class MuteCommand : Command {
|
|||
}
|
||||
|
||||
await toMute.AddRoleAsync(role, requestOptions);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (!hasDuration) {
|
||||
Error(Messages.DurationRequiredForTimeOuts, false);
|
||||
return;
|
||||
|
@ -118,4 +120,4 @@ public class MuteCommand : Command {
|
|||
await toMute.SetTimeOutAsync(duration, requestOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue