mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-01-31 09:09:00 +03:00
Fix issues caused by refactor
This commit is contained in:
parent
3b12fb7e41
commit
7dbc4472f7
8 changed files with 28 additions and 108 deletions
|
@ -11,7 +11,7 @@ public static class Boyfriend {
|
|||
|
||||
private static readonly DiscordSocketConfig Config = new() {
|
||||
MessageCacheSize = 250,
|
||||
GatewayIntents = GatewayIntents.AllUnprivileged | GatewayIntents.MessageContent | GatewayIntents.GuildMembers,
|
||||
GatewayIntents = (GatewayIntents.AllUnprivileged | GatewayIntents.MessageContent | GatewayIntents.GuildMembers) & ~GatewayIntents.GuildInvites,
|
||||
AlwaysDownloadUsers = true,
|
||||
AlwaysResolveStickers = false,
|
||||
AlwaysDownloadDefaultStickers = false,
|
||||
|
@ -103,11 +103,11 @@ public static class Boyfriend {
|
|||
}
|
||||
|
||||
public static async Task WriteGuildConfigAsync(ulong id) {
|
||||
var json = JsonConvert.SerializeObject(GuildConfigDictionary[id], Formatting.Indented);
|
||||
var removedRoles = JsonConvert.SerializeObject(RemovedRolesDictionary[id], Formatting.Indented);
|
||||
await File.WriteAllTextAsync($"config_{id}.json", JsonConvert.SerializeObject(GuildConfigDictionary[id], Formatting.Indented));
|
||||
|
||||
await File.WriteAllTextAsync($"config_{id}.json", json);
|
||||
await File.WriteAllTextAsync($"removedroles_{id}.json", removedRoles);
|
||||
if (RemovedRolesDictionary.TryGetValue(id, out var removedRoles))
|
||||
await File.WriteAllTextAsync($"removedroles_{id}.json",
|
||||
JsonConvert.SerializeObject(removedRoles, Formatting.Indented));
|
||||
}
|
||||
|
||||
public static Dictionary<string, string> GetGuildConfig(ulong id) {
|
||||
|
|
|
@ -41,7 +41,7 @@ public sealed class CommandProcessor {
|
|||
Utils.SetCurrentLanguage(guild.Id);
|
||||
|
||||
if (GetMember().Roles.Contains(muteRole)) {
|
||||
await Context.Message.ReplyAsync(Messages.UserCannotUnmuteThemselves);
|
||||
_ = Context.Message.ReplyAsync(Messages.UserCannotUnmuteThemselves);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -51,11 +51,6 @@ public sealed class CommandProcessor {
|
|||
RunCommandOnLine(list[i], cleanList[i], config["Prefix"]);
|
||||
|
||||
if (_stackedReplyMessage.Length > 0) _ = Context.Channel.TriggerTypingAsync();
|
||||
var member = Boyfriend.Client.GetGuild(Context.Guild.Id)
|
||||
.GetUser(Context.User.Id); // Getting an up-to-date copy
|
||||
if (member is null || member.Roles.Contains(muteRole)
|
||||
|| member.TimedOutUntil.GetValueOrDefault(DateTimeOffset.UnixEpoch).ToUnixTimeSeconds() >
|
||||
DateTimeOffset.Now.ToUnixTimeSeconds()) break;
|
||||
}
|
||||
|
||||
await Task.WhenAll(_tasks);
|
||||
|
@ -67,8 +62,8 @@ public sealed class CommandProcessor {
|
|||
}
|
||||
|
||||
private void RunCommandOnLine(string line, string cleanLine, string prefix) {
|
||||
var prefixed = line[..prefix.Length] == prefix;
|
||||
if (!prefixed && line[..Mention.Length] is not Mention) return;
|
||||
var prefixed = line.StartsWith(prefix);
|
||||
if (!prefixed && !line.StartsWith(Mention)) return;
|
||||
foreach (var command in Commands) {
|
||||
var lineNoMention = line.Remove(0, prefixed ? prefix.Length : Mention.Length);
|
||||
if (!command.Aliases.Contains(lineNoMention.Trim().Split()[0])) continue;
|
||||
|
@ -141,18 +136,15 @@ public sealed class CommandProcessor {
|
|||
}
|
||||
|
||||
if (Context.Guild.GetUser(Context.User.Id).GuildPermissions.Has(permission)
|
||||
|| Context.Guild.Owner.Id == Context.User.Id) return true;
|
||||
|| Context.Guild.OwnerId == Context.User.Id) return true;
|
||||
|
||||
Utils.SafeAppendToBuilder(_stackedReplyMessage, $"{NoAccess}{Utils.GetMessage($"UserCannot{permission}")}",
|
||||
Context.Message);
|
||||
return false;
|
||||
}
|
||||
|
||||
public SocketGuildUser? GetMember(SocketUser user, string? argument) {
|
||||
var member = Context.Guild.GetUser(user.Id);
|
||||
if (member is null && argument is not null)
|
||||
Utils.SafeAppendToBuilder(_stackedReplyMessage, $":x: {Messages.UserNotInGuild}", Context.Message);
|
||||
return member;
|
||||
public SocketGuildUser? GetMember(SocketUser user) {
|
||||
return Context.Guild.GetUser(user.Id);
|
||||
}
|
||||
|
||||
public SocketGuildUser? GetMember(string[] args, string[] cleanArgs, int index, string? argument) {
|
||||
|
|
|
@ -10,7 +10,7 @@ public sealed class BanCommand : ICommand {
|
|||
var toBan = cmd.GetUser(args, cleanArgs, 0, "ToBan");
|
||||
if (toBan is null || !cmd.HasPermission(GuildPermission.BanMembers)) return;
|
||||
|
||||
var memberToBan = cmd.GetMember(toBan, null);
|
||||
var memberToBan = cmd.GetMember(toBan);
|
||||
if (memberToBan is not null && !cmd.CanInteractWith(memberToBan, "Ban")) return;
|
||||
|
||||
var duration = CommandProcessor.GetTimeSpan(args, 1);
|
||||
|
|
|
@ -16,7 +16,7 @@ public sealed class SettingsCommand : ICommand {
|
|||
|
||||
foreach (var setting in Boyfriend.DefaultConfig) {
|
||||
var format = "{0}";
|
||||
var currentValue = config[setting.Key];
|
||||
var currentValue = config[setting.Key] is "default" ? Messages.DefaultWelcomeMessage : config[setting.Key];
|
||||
|
||||
if (setting.Key.EndsWith("Channel")) {
|
||||
if (guild.GetTextChannel(ulong.Parse(currentValue)) is not null) format = "<#{0}>";
|
||||
|
|
48
Boyfriend/Messages.Designer.cs
generated
48
Boyfriend/Messages.Designer.cs
generated
|
@ -716,15 +716,6 @@ namespace Boyfriend {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Admin log channel.
|
||||
/// </summary>
|
||||
internal static string SettingsAdminLogChannel {
|
||||
get {
|
||||
return ResourceManager.GetString("SettingsAdminLogChannel", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Bot log channel.
|
||||
/// </summary>
|
||||
|
@ -734,33 +725,6 @@ namespace Boyfriend {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Channel for event cancellation notifications.
|
||||
/// </summary>
|
||||
internal static string SettingsEventCancelledChannel {
|
||||
get {
|
||||
return ResourceManager.GetString("SettingsEventCancelledChannel", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Channel for event completion notifications.
|
||||
/// </summary>
|
||||
internal static string SettingsEventCompletedChannel {
|
||||
get {
|
||||
return ResourceManager.GetString("SettingsEventCompletedChannel", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Channel for event creation notifications.
|
||||
/// </summary>
|
||||
internal static string SettingsEventCreatedChannel {
|
||||
get {
|
||||
return ResourceManager.GetString("SettingsEventCreatedChannel", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Early event start notification offset.
|
||||
/// </summary>
|
||||
|
@ -771,20 +735,20 @@ namespace Boyfriend {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Role for event creation notifications.
|
||||
/// Looks up a localized string similar to Channel for event notifications.
|
||||
/// </summary>
|
||||
internal static string SettingsEventNotifyReceiverRole {
|
||||
internal static string SettingsEventNotificationChannel {
|
||||
get {
|
||||
return ResourceManager.GetString("SettingsEventNotifyReceiverRole", resourceCulture);
|
||||
return ResourceManager.GetString("SettingsEventNotificationChannel", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Channel for event start notifications.
|
||||
/// Looks up a localized string similar to Role for event creation notifications.
|
||||
/// </summary>
|
||||
internal static string SettingsEventStartedChannel {
|
||||
internal static string SettingsEventNotificationRole {
|
||||
get {
|
||||
return ResourceManager.GetString("SettingsEventStartedChannel", resourceCulture);
|
||||
return ResourceManager.GetString("SettingsEventNotificationRole", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -102,9 +102,6 @@
|
|||
<data name="SettingsMuteRole" xml:space="preserve">
|
||||
<value>Mute role</value>
|
||||
</data>
|
||||
<data name="SettingsAdminLogChannel" xml:space="preserve">
|
||||
<value>Admin log channel</value>
|
||||
</data>
|
||||
<data name="SettingsBotLogChannel" xml:space="preserve">
|
||||
<value>Bot log channel</value>
|
||||
</data>
|
||||
|
@ -165,14 +162,11 @@
|
|||
<data name="EventCreated" xml:space="preserve">
|
||||
<value>{0} has created event {1}! It will take place in {2} and will start <t:{3}:R>!\n{4}</value>
|
||||
</data>
|
||||
<data name="SettingsEventNotifyReceiverRole" xml:space="preserve">
|
||||
<data name="SettingsEventNotificationRole" xml:space="preserve">
|
||||
<value>Role for event creation notifications</value>
|
||||
</data>
|
||||
<data name="SettingsEventCreatedChannel" xml:space="preserve">
|
||||
<value>Channel for event creation notifications</value>
|
||||
</data>
|
||||
<data name="SettingsEventStartedChannel" xml:space="preserve">
|
||||
<value>Channel for event start notifications</value>
|
||||
<data name="SettingsEventNotificationChannel" xml:space="preserve">
|
||||
<value>Channel for event notifications</value>
|
||||
</data>
|
||||
<data name="SettingsEventStartedReceivers" xml:space="preserve">
|
||||
<value>Event start notifications receivers</value>
|
||||
|
@ -186,12 +180,6 @@
|
|||
<data name="EventCancelled" xml:space="preserve">
|
||||
<value>Event {0} is cancelled!{1}</value>
|
||||
</data>
|
||||
<data name="SettingsEventCancelledChannel" xml:space="preserve">
|
||||
<value>Channel for event cancellation notifications</value>
|
||||
</data>
|
||||
<data name="SettingsEventCompletedChannel" xml:space="preserve">
|
||||
<value>Channel for event completion notifications</value>
|
||||
</data>
|
||||
<data name="EventCompleted" xml:space="preserve">
|
||||
<value>Event {0} has completed! Duration: {1}</value>
|
||||
</data>
|
||||
|
|
|
@ -90,9 +90,6 @@
|
|||
<data name="SettingsMuteRole" xml:space="preserve">
|
||||
<value>Роль мута</value>
|
||||
</data>
|
||||
<data name="SettingsAdminLogChannel" xml:space="preserve">
|
||||
<value>Канал админ-уведомлений</value>
|
||||
</data>
|
||||
<data name="SettingsBotLogChannel" xml:space="preserve">
|
||||
<value>Канал бот-уведомлений</value>
|
||||
</data>
|
||||
|
@ -156,14 +153,11 @@
|
|||
<data name="EventCreated" xml:space="preserve">
|
||||
<value>{0} создал событие {1}! Оно пройдёт в {2} и начнётся <t:{3}:R>!\n{4}</value>
|
||||
</data>
|
||||
<data name="SettingsEventNotifyReceiverRole" xml:space="preserve">
|
||||
<data name="SettingsEventNotificationRole" xml:space="preserve">
|
||||
<value>Роль для уведомлений о создании событий</value>
|
||||
</data>
|
||||
<data name="SettingsEventCreatedChannel" xml:space="preserve">
|
||||
<value>Канал для уведомлений о создании событий</value>
|
||||
</data>
|
||||
<data name="SettingsEventStartedChannel" xml:space="preserve">
|
||||
<value>Канал для уведомлений о начале событий</value>
|
||||
<data name="SettingsEventNotificationChannel" xml:space="preserve">
|
||||
<value>Канал для уведомлений о событиях</value>
|
||||
</data>
|
||||
<data name="SettingsEventStartedReceivers" xml:space="preserve">
|
||||
<value>Получатели уведомлений о начале событий</value>
|
||||
|
@ -177,12 +171,6 @@
|
|||
<data name="EventCancelled" xml:space="preserve">
|
||||
<value>Событие {0} отменено!{1}</value>
|
||||
</data>
|
||||
<data name="SettingsEventCancelledChannel" xml:space="preserve">
|
||||
<value>Канал для уведомлений о отмене событий</value>
|
||||
</data>
|
||||
<data name="SettingsEventCompletedChannel" xml:space="preserve">
|
||||
<value>Канал для уведомлений о завершении событий</value>
|
||||
</data>
|
||||
<data name="EventCompleted" xml:space="preserve">
|
||||
<value>Событие {0} завершено! Продолжительность: {1}</value>
|
||||
</data>
|
||||
|
|
|
@ -90,9 +90,6 @@
|
|||
<data name="SettingsMuteRole" xml:space="preserve">
|
||||
<value>роль замученного</value>
|
||||
</data>
|
||||
<data name="SettingsAdminLogChannel" xml:space="preserve">
|
||||
<value>канал админ-уведомлений</value>
|
||||
</data>
|
||||
<data name="SettingsBotLogChannel" xml:space="preserve">
|
||||
<value>канал бот-уведомлений</value>
|
||||
</data>
|
||||
|
@ -156,14 +153,11 @@
|
|||
<data name="EventCreated" xml:space="preserve">
|
||||
<value>{0} приготовил новый квест {1}! он пройдёт в {2} и начнётся <t:{3}:R>!\n{4}</value>
|
||||
</data>
|
||||
<data name="SettingsEventNotifyReceiverRole" xml:space="preserve">
|
||||
<data name="SettingsEventNotificationRole" xml:space="preserve">
|
||||
<value>роль для уведомлений о создании квеста</value>
|
||||
</data>
|
||||
<data name="SettingsEventCreatedChannel" xml:space="preserve">
|
||||
<value>канал для уведомлений о создании квеста</value>
|
||||
</data>
|
||||
<data name="SettingsEventStartedChannel" xml:space="preserve">
|
||||
<value>канал для уведомлений о начале квеста</value>
|
||||
<data name="SettingsEventNotificationChannel" xml:space="preserve">
|
||||
<value>канал для уведомлений о квестах</value>
|
||||
</data>
|
||||
<data name="SettingsEventStartedReceivers" xml:space="preserve">
|
||||
<value>получатели уведомлений о начале квеста</value>
|
||||
|
@ -177,12 +171,6 @@
|
|||
<data name="EventCancelled" xml:space="preserve">
|
||||
<value>квест {0} отменен!{1}</value>
|
||||
</data>
|
||||
<data name="SettingsEventCancelledChannel" xml:space="preserve">
|
||||
<value>канал для уведомлений о отмене событий</value>
|
||||
</data>
|
||||
<data name="SettingsEventCompletedChannel" xml:space="preserve">
|
||||
<value>канал для уведомлений о завершении квеста</value>
|
||||
</data>
|
||||
<data name="EventCompleted" xml:space="preserve">
|
||||
<value>квест {0} завершен! все это длилось {1}</value>
|
||||
</data>
|
||||
|
|
Loading…
Reference in a new issue