forked from TeamInklings/Octobot
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() {
|
private static readonly DiscordSocketConfig Config = new() {
|
||||||
MessageCacheSize = 250,
|
MessageCacheSize = 250,
|
||||||
GatewayIntents = GatewayIntents.AllUnprivileged | GatewayIntents.MessageContent | GatewayIntents.GuildMembers,
|
GatewayIntents = (GatewayIntents.AllUnprivileged | GatewayIntents.MessageContent | GatewayIntents.GuildMembers) & ~GatewayIntents.GuildInvites,
|
||||||
AlwaysDownloadUsers = true,
|
AlwaysDownloadUsers = true,
|
||||||
AlwaysResolveStickers = false,
|
AlwaysResolveStickers = false,
|
||||||
AlwaysDownloadDefaultStickers = false,
|
AlwaysDownloadDefaultStickers = false,
|
||||||
|
@ -103,11 +103,11 @@ public static class Boyfriend {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task WriteGuildConfigAsync(ulong id) {
|
public static async Task WriteGuildConfigAsync(ulong id) {
|
||||||
var json = JsonConvert.SerializeObject(GuildConfigDictionary[id], Formatting.Indented);
|
await File.WriteAllTextAsync($"config_{id}.json", JsonConvert.SerializeObject(GuildConfigDictionary[id], Formatting.Indented));
|
||||||
var removedRoles = JsonConvert.SerializeObject(RemovedRolesDictionary[id], Formatting.Indented);
|
|
||||||
|
|
||||||
await File.WriteAllTextAsync($"config_{id}.json", json);
|
if (RemovedRolesDictionary.TryGetValue(id, out var removedRoles))
|
||||||
await File.WriteAllTextAsync($"removedroles_{id}.json", removedRoles);
|
await File.WriteAllTextAsync($"removedroles_{id}.json",
|
||||||
|
JsonConvert.SerializeObject(removedRoles, Formatting.Indented));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Dictionary<string, string> GetGuildConfig(ulong id) {
|
public static Dictionary<string, string> GetGuildConfig(ulong id) {
|
||||||
|
|
|
@ -41,7 +41,7 @@ public sealed class CommandProcessor {
|
||||||
Utils.SetCurrentLanguage(guild.Id);
|
Utils.SetCurrentLanguage(guild.Id);
|
||||||
|
|
||||||
if (GetMember().Roles.Contains(muteRole)) {
|
if (GetMember().Roles.Contains(muteRole)) {
|
||||||
await Context.Message.ReplyAsync(Messages.UserCannotUnmuteThemselves);
|
_ = Context.Message.ReplyAsync(Messages.UserCannotUnmuteThemselves);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,11 +51,6 @@ public sealed class CommandProcessor {
|
||||||
RunCommandOnLine(list[i], cleanList[i], config["Prefix"]);
|
RunCommandOnLine(list[i], cleanList[i], config["Prefix"]);
|
||||||
|
|
||||||
if (_stackedReplyMessage.Length > 0) _ = Context.Channel.TriggerTypingAsync();
|
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);
|
await Task.WhenAll(_tasks);
|
||||||
|
@ -67,8 +62,8 @@ public sealed class CommandProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RunCommandOnLine(string line, string cleanLine, string prefix) {
|
private void RunCommandOnLine(string line, string cleanLine, string prefix) {
|
||||||
var prefixed = line[..prefix.Length] == prefix;
|
var prefixed = line.StartsWith(prefix);
|
||||||
if (!prefixed && line[..Mention.Length] is not Mention) return;
|
if (!prefixed && !line.StartsWith(Mention)) return;
|
||||||
foreach (var command in Commands) {
|
foreach (var command in Commands) {
|
||||||
var lineNoMention = line.Remove(0, prefixed ? prefix.Length : Mention.Length);
|
var lineNoMention = line.Remove(0, prefixed ? prefix.Length : Mention.Length);
|
||||||
if (!command.Aliases.Contains(lineNoMention.Trim().Split()[0])) continue;
|
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)
|
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}")}",
|
Utils.SafeAppendToBuilder(_stackedReplyMessage, $"{NoAccess}{Utils.GetMessage($"UserCannot{permission}")}",
|
||||||
Context.Message);
|
Context.Message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SocketGuildUser? GetMember(SocketUser user, string? argument) {
|
public SocketGuildUser? GetMember(SocketUser user) {
|
||||||
var member = Context.Guild.GetUser(user.Id);
|
return 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(string[] args, string[] cleanArgs, int index, string? argument) {
|
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");
|
var toBan = cmd.GetUser(args, cleanArgs, 0, "ToBan");
|
||||||
if (toBan is null || !cmd.HasPermission(GuildPermission.BanMembers)) return;
|
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;
|
if (memberToBan is not null && !cmd.CanInteractWith(memberToBan, "Ban")) return;
|
||||||
|
|
||||||
var duration = CommandProcessor.GetTimeSpan(args, 1);
|
var duration = CommandProcessor.GetTimeSpan(args, 1);
|
||||||
|
|
|
@ -16,7 +16,7 @@ public sealed class SettingsCommand : ICommand {
|
||||||
|
|
||||||
foreach (var setting in Boyfriend.DefaultConfig) {
|
foreach (var setting in Boyfriend.DefaultConfig) {
|
||||||
var format = "{0}";
|
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 (setting.Key.EndsWith("Channel")) {
|
||||||
if (guild.GetTextChannel(ulong.Parse(currentValue)) is not null) format = "<#{0}>";
|
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>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Bot log channel.
|
/// Looks up a localized string similar to Bot log channel.
|
||||||
/// </summary>
|
/// </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>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Early event start notification offset.
|
/// Looks up a localized string similar to Early event start notification offset.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -771,20 +735,20 @@ namespace Boyfriend {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
internal static string SettingsEventNotifyReceiverRole {
|
internal static string SettingsEventNotificationChannel {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("SettingsEventNotifyReceiverRole", resourceCulture);
|
return ResourceManager.GetString("SettingsEventNotificationChannel", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
internal static string SettingsEventStartedChannel {
|
internal static string SettingsEventNotificationRole {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("SettingsEventStartedChannel", resourceCulture);
|
return ResourceManager.GetString("SettingsEventNotificationRole", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,9 +102,6 @@
|
||||||
<data name="SettingsMuteRole" xml:space="preserve">
|
<data name="SettingsMuteRole" xml:space="preserve">
|
||||||
<value>Mute role</value>
|
<value>Mute role</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SettingsAdminLogChannel" xml:space="preserve">
|
|
||||||
<value>Admin log channel</value>
|
|
||||||
</data>
|
|
||||||
<data name="SettingsBotLogChannel" xml:space="preserve">
|
<data name="SettingsBotLogChannel" xml:space="preserve">
|
||||||
<value>Bot log channel</value>
|
<value>Bot log channel</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -165,14 +162,11 @@
|
||||||
<data name="EventCreated" xml:space="preserve">
|
<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>
|
<value>{0} has created event {1}! It will take place in {2} and will start <t:{3}:R>!\n{4}</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SettingsEventNotifyReceiverRole" xml:space="preserve">
|
<data name="SettingsEventNotificationRole" xml:space="preserve">
|
||||||
<value>Role for event creation notifications</value>
|
<value>Role for event creation notifications</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SettingsEventCreatedChannel" xml:space="preserve">
|
<data name="SettingsEventNotificationChannel" xml:space="preserve">
|
||||||
<value>Channel for event creation notifications</value>
|
<value>Channel for event notifications</value>
|
||||||
</data>
|
|
||||||
<data name="SettingsEventStartedChannel" xml:space="preserve">
|
|
||||||
<value>Channel for event start notifications</value>
|
|
||||||
</data>
|
</data>
|
||||||
<data name="SettingsEventStartedReceivers" xml:space="preserve">
|
<data name="SettingsEventStartedReceivers" xml:space="preserve">
|
||||||
<value>Event start notifications receivers</value>
|
<value>Event start notifications receivers</value>
|
||||||
|
@ -186,12 +180,6 @@
|
||||||
<data name="EventCancelled" xml:space="preserve">
|
<data name="EventCancelled" xml:space="preserve">
|
||||||
<value>Event {0} is cancelled!{1}</value>
|
<value>Event {0} is cancelled!{1}</value>
|
||||||
</data>
|
</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">
|
<data name="EventCompleted" xml:space="preserve">
|
||||||
<value>Event {0} has completed! Duration: {1}</value>
|
<value>Event {0} has completed! Duration: {1}</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
|
@ -90,9 +90,6 @@
|
||||||
<data name="SettingsMuteRole" xml:space="preserve">
|
<data name="SettingsMuteRole" xml:space="preserve">
|
||||||
<value>Роль мута</value>
|
<value>Роль мута</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SettingsAdminLogChannel" xml:space="preserve">
|
|
||||||
<value>Канал админ-уведомлений</value>
|
|
||||||
</data>
|
|
||||||
<data name="SettingsBotLogChannel" xml:space="preserve">
|
<data name="SettingsBotLogChannel" xml:space="preserve">
|
||||||
<value>Канал бот-уведомлений</value>
|
<value>Канал бот-уведомлений</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -156,14 +153,11 @@
|
||||||
<data name="EventCreated" xml:space="preserve">
|
<data name="EventCreated" xml:space="preserve">
|
||||||
<value>{0} создал событие {1}! Оно пройдёт в {2} и начнётся <t:{3}:R>!\n{4}</value>
|
<value>{0} создал событие {1}! Оно пройдёт в {2} и начнётся <t:{3}:R>!\n{4}</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SettingsEventNotifyReceiverRole" xml:space="preserve">
|
<data name="SettingsEventNotificationRole" xml:space="preserve">
|
||||||
<value>Роль для уведомлений о создании событий</value>
|
<value>Роль для уведомлений о создании событий</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SettingsEventCreatedChannel" xml:space="preserve">
|
<data name="SettingsEventNotificationChannel" xml:space="preserve">
|
||||||
<value>Канал для уведомлений о создании событий</value>
|
<value>Канал для уведомлений о событиях</value>
|
||||||
</data>
|
|
||||||
<data name="SettingsEventStartedChannel" xml:space="preserve">
|
|
||||||
<value>Канал для уведомлений о начале событий</value>
|
|
||||||
</data>
|
</data>
|
||||||
<data name="SettingsEventStartedReceivers" xml:space="preserve">
|
<data name="SettingsEventStartedReceivers" xml:space="preserve">
|
||||||
<value>Получатели уведомлений о начале событий</value>
|
<value>Получатели уведомлений о начале событий</value>
|
||||||
|
@ -177,12 +171,6 @@
|
||||||
<data name="EventCancelled" xml:space="preserve">
|
<data name="EventCancelled" xml:space="preserve">
|
||||||
<value>Событие {0} отменено!{1}</value>
|
<value>Событие {0} отменено!{1}</value>
|
||||||
</data>
|
</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">
|
<data name="EventCompleted" xml:space="preserve">
|
||||||
<value>Событие {0} завершено! Продолжительность: {1}</value>
|
<value>Событие {0} завершено! Продолжительность: {1}</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
|
@ -90,9 +90,6 @@
|
||||||
<data name="SettingsMuteRole" xml:space="preserve">
|
<data name="SettingsMuteRole" xml:space="preserve">
|
||||||
<value>роль замученного</value>
|
<value>роль замученного</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SettingsAdminLogChannel" xml:space="preserve">
|
|
||||||
<value>канал админ-уведомлений</value>
|
|
||||||
</data>
|
|
||||||
<data name="SettingsBotLogChannel" xml:space="preserve">
|
<data name="SettingsBotLogChannel" xml:space="preserve">
|
||||||
<value>канал бот-уведомлений</value>
|
<value>канал бот-уведомлений</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -156,14 +153,11 @@
|
||||||
<data name="EventCreated" xml:space="preserve">
|
<data name="EventCreated" xml:space="preserve">
|
||||||
<value>{0} приготовил новый квест {1}! он пройдёт в {2} и начнётся <t:{3}:R>!\n{4}</value>
|
<value>{0} приготовил новый квест {1}! он пройдёт в {2} и начнётся <t:{3}:R>!\n{4}</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SettingsEventNotifyReceiverRole" xml:space="preserve">
|
<data name="SettingsEventNotificationRole" xml:space="preserve">
|
||||||
<value>роль для уведомлений о создании квеста</value>
|
<value>роль для уведомлений о создании квеста</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SettingsEventCreatedChannel" xml:space="preserve">
|
<data name="SettingsEventNotificationChannel" xml:space="preserve">
|
||||||
<value>канал для уведомлений о создании квеста</value>
|
<value>канал для уведомлений о квестах</value>
|
||||||
</data>
|
|
||||||
<data name="SettingsEventStartedChannel" xml:space="preserve">
|
|
||||||
<value>канал для уведомлений о начале квеста</value>
|
|
||||||
</data>
|
</data>
|
||||||
<data name="SettingsEventStartedReceivers" xml:space="preserve">
|
<data name="SettingsEventStartedReceivers" xml:space="preserve">
|
||||||
<value>получатели уведомлений о начале квеста</value>
|
<value>получатели уведомлений о начале квеста</value>
|
||||||
|
@ -177,12 +171,6 @@
|
||||||
<data name="EventCancelled" xml:space="preserve">
|
<data name="EventCancelled" xml:space="preserve">
|
||||||
<value>квест {0} отменен!{1}</value>
|
<value>квест {0} отменен!{1}</value>
|
||||||
</data>
|
</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">
|
<data name="EventCompleted" xml:space="preserve">
|
||||||
<value>квест {0} завершен! все это длилось {1}</value>
|
<value>квест {0} завершен! все это длилось {1}</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
Reference in a new issue