mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-04-20 00:43:36 +03:00
exclude more generated code + fix issues
This commit is contained in:
parent
4260136002
commit
c36ace33b0
4 changed files with 43 additions and 35 deletions
9
.github/workflows/resharper.yml
vendored
9
.github/workflows/resharper.yml
vendored
|
@ -25,9 +25,6 @@ jobs:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
#- name: Setup .NET Core SDK
|
|
||||||
# uses: actions/setup-dotnet@v3.0.3
|
|
||||||
|
|
||||||
- name: Restore dependencies and tools
|
- name: Restore dependencies and tools
|
||||||
run: dotnet restore
|
run: dotnet restore
|
||||||
|
|
||||||
|
@ -36,5 +33,9 @@ jobs:
|
||||||
with:
|
with:
|
||||||
solutionPath: ./Boyfriend-CSharp.sln
|
solutionPath: ./Boyfriend-CSharp.sln
|
||||||
exclude: |
|
exclude: |
|
||||||
**Messages.Designer.cs
|
**Messages.**
|
||||||
|
**.g.cs
|
||||||
|
**.editorconfig
|
||||||
|
**.AssemblyInfo.cs
|
||||||
|
ignoreIssueType: InvertIf
|
||||||
solutionWideAnalysis: true
|
solutionWideAnalysis: true
|
||||||
|
|
|
@ -61,7 +61,7 @@ public static class Boyfriend {
|
||||||
private static async Task Init() {
|
private static async Task Init() {
|
||||||
var token = (await File.ReadAllTextAsync("token.txt")).Trim();
|
var token = (await File.ReadAllTextAsync("token.txt")).Trim();
|
||||||
|
|
||||||
Client.Log += x => Log(x);
|
Client.Log += Log;
|
||||||
|
|
||||||
await Client.LoginAsync(TokenType.Bot, token);
|
await Client.LoginAsync(TokenType.Bot, token);
|
||||||
await Client.StartAsync();
|
await Client.StartAsync();
|
||||||
|
@ -152,4 +152,3 @@ public static class Boyfriend {
|
||||||
return removedRoles;
|
return removedRoles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,8 @@ public sealed class CommandProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Reply(string response, string? customEmoji = null) {
|
public void Reply(string response, string? customEmoji = null) {
|
||||||
Utils.SafeAppendToBuilder(_stackedReplyMessage, $"{customEmoji ?? ReplyEmojis.Success} {response}", Context.Message);
|
Utils.SafeAppendToBuilder(_stackedReplyMessage, $"{customEmoji ?? ReplyEmojis.Success} {response}",
|
||||||
|
Context.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Audit(string action, bool isPublic = true) {
|
public void Audit(string action, bool isPublic = true) {
|
||||||
|
@ -127,17 +128,21 @@ public sealed class CommandProcessor {
|
||||||
|
|
||||||
public bool HasPermission(GuildPermission permission) {
|
public bool HasPermission(GuildPermission permission) {
|
||||||
if (!Context.Guild.CurrentUser.GuildPermissions.Has(permission)) {
|
if (!Context.Guild.CurrentUser.GuildPermissions.Has(permission)) {
|
||||||
Utils.SafeAppendToBuilder(_stackedReplyMessage, $"{ReplyEmojis.NoPermission} {Utils.GetMessage($"BotCannot{permission}")}",
|
Utils.SafeAppendToBuilder(_stackedReplyMessage,
|
||||||
|
$"{ReplyEmojis.NoPermission} {Utils.GetMessage($"BotCannot{permission}")}",
|
||||||
Context.Message);
|
Context.Message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Context.Guild.GetUser(Context.User.Id).GuildPermissions.Has(permission)
|
if (!Context.Guild.GetUser(Context.User.Id).GuildPermissions.Has(permission)
|
||||||
|| Context.Guild.OwnerId == Context.User.Id) return true;
|
&& Context.Guild.OwnerId != Context.User.Id) {
|
||||||
|
Utils.SafeAppendToBuilder(_stackedReplyMessage,
|
||||||
|
$"{ReplyEmojis.NoPermission} {Utils.GetMessage($"UserCannot{permission}")}",
|
||||||
|
Context.Message);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Utils.SafeAppendToBuilder(_stackedReplyMessage, $"{ReplyEmojis.NoPermission} {Utils.GetMessage($"UserCannot{permission}")}",
|
return true;
|
||||||
Context.Message);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SocketGuildUser? GetMember(SocketUser user) {
|
public SocketGuildUser? GetMember(SocketUser user) {
|
||||||
|
@ -202,11 +207,14 @@ public sealed class CommandProcessor {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i <= max) return i;
|
if (i > max) {
|
||||||
Utils.SafeAppendToBuilder(_stackedReplyMessage,
|
Utils.SafeAppendToBuilder(_stackedReplyMessage,
|
||||||
$"{ReplyEmojis.InvalidArgument} {string.Format(Utils.GetMessage($"{argument}TooLarge"), max.ToString())}",
|
$"{ReplyEmojis.InvalidArgument} {string.Format(Utils.GetMessage($"{argument}TooLarge"), max.ToString())}",
|
||||||
Context.Message);
|
Context.Message);
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TimeSpan GetTimeSpan(string[] args, int index) {
|
public static TimeSpan GetTimeSpan(string[] args, int index) {
|
||||||
|
@ -268,9 +276,12 @@ public sealed class CommandProcessor {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Context.Guild.Owner.Id == Context.User.Id || GetMember().Hierarchy > user.Hierarchy) return true;
|
if (Context.Guild.Owner.Id != Context.User.Id && GetMember().Hierarchy <= user.Hierarchy) {
|
||||||
Utils.SafeAppendToBuilder(_stackedReplyMessage,
|
Utils.SafeAppendToBuilder(_stackedReplyMessage,
|
||||||
$"{ReplyEmojis.CantInteract} {Utils.GetMessage($"UserCannot{action}Target")}", Context.Message);
|
$"{ReplyEmojis.CantInteract} {Utils.GetMessage($"UserCannot{action}Target")}", Context.Message);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using Discord;
|
||||||
using Discord;
|
|
||||||
using Discord.Rest;
|
using Discord.Rest;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
|
|
||||||
|
@ -9,17 +8,16 @@ public static class EventHandler {
|
||||||
private static readonly DiscordSocketClient Client = Boyfriend.Client;
|
private static readonly DiscordSocketClient Client = Boyfriend.Client;
|
||||||
private static bool _sendReadyMessages = true;
|
private static bool _sendReadyMessages = true;
|
||||||
|
|
||||||
[SuppressMessage("ReSharper", "ConvertClosureToMethodGroup")]
|
|
||||||
public static void InitEvents() {
|
public static void InitEvents() {
|
||||||
Client.Ready += () => ReadyEvent();
|
Client.Ready += ReadyEvent;
|
||||||
Client.MessageDeleted += (x, y) => MessageDeletedEvent(x, y);
|
Client.MessageDeleted += MessageDeletedEvent;
|
||||||
Client.MessageReceived += x => MessageReceivedEvent(x);
|
Client.MessageReceived += MessageReceivedEvent;
|
||||||
Client.MessageUpdated += (x, y, z) => MessageUpdatedEvent(x, y, z);
|
Client.MessageUpdated += MessageUpdatedEvent;
|
||||||
Client.UserJoined += x => UserJoinedEvent(x);
|
Client.UserJoined += UserJoinedEvent;
|
||||||
Client.GuildScheduledEventCreated += x => ScheduledEventCreatedEvent(x);
|
Client.GuildScheduledEventCreated += ScheduledEventCreatedEvent;
|
||||||
Client.GuildScheduledEventCancelled += x => ScheduledEventCancelledEvent(x);
|
Client.GuildScheduledEventCancelled += ScheduledEventCancelledEvent;
|
||||||
Client.GuildScheduledEventStarted += x => ScheduledEventStartedEvent(x);
|
Client.GuildScheduledEventStarted += ScheduledEventStartedEvent;
|
||||||
Client.GuildScheduledEventCompleted += x => ScheduledEventCompletedEvent(x);
|
Client.GuildScheduledEventCompleted += ScheduledEventCompletedEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Task ReadyEvent() {
|
private static Task ReadyEvent() {
|
||||||
|
@ -176,4 +174,3 @@ public static class EventHandler {
|
||||||
Utils.GetHumanizedTimeOffset(DateTimeOffset.Now.Subtract(scheduledEvent.StartTime))));
|
Utils.GetHumanizedTimeOffset(DateTimeOffset.Now.Subtract(scheduledEvent.StartTime))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue