This repository was archived by the owner on Dec 27, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHook.cs
More file actions
70 lines (65 loc) · 2.44 KB
/
Hook.cs
File metadata and controls
70 lines (65 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using DSharpPlus.Entities;
using DSharpPlus.VoiceNext;
using HarmonyLib;
using TagLib;
namespace CatBot
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "<Pending>")]
internal class Hook
{
[HarmonyPatch("DSharpPlus.VoiceNext.Entities.VoiceStateUpdatePayload", "Deafened", MethodType.Setter)]
internal class DeafenHook
{
static readonly bool isDeafen = true;
static bool Prefix(ref bool value)
{
value = isDeafen;
return true;
}
}
[HarmonyPatch(typeof(VoiceNextConnection), nameof(VoiceNextConnection.SendSpeakingAsync))]
internal class SendSpeakingHook
{
static bool Prefix(VoiceNextConnection __instance, ref bool speaking)
{
if (__instance.TargetChannel.Type == DiscordChannelType.Stage)
speaking = true;
return true;
}
}
[HarmonyPatch(typeof(Picture), nameof(Picture.GetExtensionFromMime))]
internal class GetExtensionFromMimeHook
{
static bool Prefix(string mime, ref string __result)
{
if (mime == "image/jpg")
{
__result = "jpg";
return false;
}
return true;
}
}
//
//[HarmonyPatch(typeof(CommandsNextExtension), "HandleCommandsAsync")]
//internal class HandleCommandAsyncHook
//{
// static bool CheckExcludedBot(DiscordUser user) => user.IsBot && !user.IsBotExcluded();
// static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
// {
// foreach (var instruction in instructions)
// {
// if (instruction.opcode == OpCodes.Call)
// {
// if (instruction.operand is MethodInfo methodInfo && methodInfo.Name == "get_IsBot")
// {
// yield return new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(HandleCommandAsyncHook), nameof(CheckExcludedBot)));
// continue;
// }
// }
// yield return instruction;
// }
// }
//}
}
}