-
Notifications
You must be signed in to change notification settings - Fork 0
/
UtilityBot
1176 lines (1097 loc) · 55.7 KB
/
UtilityBot
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Threading.Tasks;
using DSharpPlus;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Interactivity;
using DSharpPlus.Interactivity.Extensions;
using DSharpPlus.Interactivity.Enums;
using DSharpPlus.Entities;
using DSharpPlus.VoiceNext;
using DescriptionAttribute = DSharpPlus.CommandsNext.Attributes.DescriptionAttribute;
namespace DiscordBotAttempt3
{
public static class Program
{
static DiscordClient discord;
static void Main(string[] args)
{
MainAsync(args).ConfigureAwait(false).GetAwaiter().GetResult();
}
static async Task MainAsync(string[] args)
{
discord = new DiscordClient(new DiscordConfiguration
{
Token = TOKENHERE,
TokenType = TokenType.Bot,
LogTimestampFormat = "MMM dd yyyy - hh:mm:ss tt",
});
discord.UseInteractivity(new InteractivityConfiguration()
{
PollBehaviour = PollBehaviour.KeepEmojis,
Timeout = TimeSpan.FromSeconds(30)
});
var commands = discord.UseCommandsNext(new CommandsNextConfiguration()
{
StringPrefixes = new[] { "-/" }
});
discord.GuildMemberAdded += async (s, e) =>
{
await e.Member.SendMessageAsync($"Welcome to {e.Guild.Name}");
};
discord.SocketErrored += async (s, e) =>
{
await discord.GetChannelAsync(768501915104968755).Result.SendMessageAsync("Hey rock man, somethings wrong with me");
await discord.GetChannelAsync(768501915104968755).Result.SendMessageAsync($"Error: {e.Exception}" +
$"Handling: {e.Handled}");
};
discord.UnknownEvent += async (s, e) =>
{
await discord.GetChannelAsync(768501915104968755).Result.SendMessageAsync("Hey rock man, somethings wrong with me");
await discord.GetChannelAsync(768501915104968755).Result.SendMessageAsync($"{e.EventName} has happened" +
$"Handling: {e.Handled}" +
$"Info: {e.Json}");
};
discord.Resumed += async (s, e) =>
{
await discord.GetChannelAsync(768501915104968755).Result.SendMessageAsync("Resumed client" +
$"Handling: {e.Handled}");
};
commands.RegisterCommands<MyCommands>();
await discord.ConnectAsync();
await Task.Delay(-1);
}
}
public class MyCommands : BaseCommandModule
{
[Command("ban"), Description("Bans specified user")]
[RequirePermissions(Permissions.BanMembers)]
public async Task Ban(CommandContext ctx, DiscordMember member, string reason)
{
try
{
await ctx.Guild.BanMemberAsync(member);
await member.SendMessageAsync($"You have been banned from {ctx.Guild.Name} for {reason}");
await ctx.RespondAsync($"Successfully banned {member.DisplayName} for {reason}");
}
catch
{
await ctx.RespondAsync("Error: Could not ban member");
}
}
[Command("unban"), Description("Unbans specified user")]
[RequirePermissions(Permissions.BanMembers)]
public async Task Unban(CommandContext ctx, DiscordUser user)
{
await ctx.Guild.UnbanMemberAsync(user.Id);
await ctx.RespondAsync($"Successfully unbanned {user.Username}");
}
[Command("check"), Description("Checks specifics about whether BehemothBot is online")]
public async Task Check(CommandContext ctx)
{
await ctx.RespondAsync("If you are only seeing this then BehemothBot is partially offline (JavaScript portion). If you are only seeing this then most commands will work because BehemothBot is mostly built upon a D# client");
}
[Command("kick"), Description("Kicks specified user")]
[RequirePermissions(Permissions.KickMembers)]
public async Task Kick(CommandContext ctx, DiscordMember member, string reason)
{
try
{
await member.SendMessageAsync($"You have been kicked from {ctx.Guild.Name}.");
await ctx.Guild.BanMemberAsync(member);
await ctx.Guild.UnbanMemberAsync(member.Id, reason);
await ctx.RespondAsync($"Successfully kicked {member.DisplayName}");
} catch
{
await ctx.RespondAsync("Error: Could not kick member");
}
}
[Command("ping"), Description("Checks the latency of the client to the server, check if BehemothBot is online")]
public async Task Ping(CommandContext ctx)
{
var embed = new DiscordEmbedBuilder
{
Title = "BehemothBot",
Description = $"{ctx.Client.Ping.ToString()} MS",
};
await ctx.RespondAsync(embed: embed);
}
[Command("serverinfo"), Description("Provides basic information about the discord server")]
public async Task Serverinfo(CommandContext ctx)
{
var embed = new DiscordEmbedBuilder
{
Title = ctx.Guild.Name,
ImageUrl = ctx.Guild.IconUrl,
Description = $"This server has {ctx.Guild.MemberCount} members, {ctx.Guild.Channels.Count} channels, and {ctx.Guild.Roles.Count} roles. {ctx.Guild.Name} was created on {ctx.Guild.Owner.JoinedAt.DateTime} and is owned by {ctx.Guild.Owner.DisplayName}",
Color = DiscordColor.Gold,
};
await ctx.RespondAsync(embed: embed);
}
[Command("userinfo"), Description("Provides basic information about the discord user, this version of the command requires the users mention.")]
public async Task Userinfo(CommandContext ctx, DiscordMember member)
{
var user = member.Equals(ctx.User);
switch (user)
{
case true:
var embed = new DiscordEmbedBuilder
{
Title = member.DisplayName,
ImageUrl = member.AvatarUrl,
Description = $"Your account was created on {member.CreationTimestamp.DateTime}. You joined this server on {member.JoinedAt.DateTime}",
Color = DiscordColor.CornflowerBlue,
};
await ctx.RespondAsync(embed: embed);
break;
case false:
var embed2 = new DiscordEmbedBuilder
{
Title = member.DisplayName,
ImageUrl = member.AvatarUrl,
Description = $"This users account was created on {member.CreationTimestamp.DateTime}. They joined this server on {member.JoinedAt.DateTime}",
Color = DiscordColor.CornflowerBlue,
};
await ctx.RespondAsync(embed: embed2);
break;
}
}
[Command("userinfo2"), Description("Provides basic information about the discord user, this version of the command requires the users ID.")]
public async Task Userinfo2(CommandContext ctx, long uid)
{
var member = ctx.Guild.GetMemberAsync(Convert.ToUInt64(uid)).Result;
var self = member.Equals(ctx.User);
switch (self)
{
case true:
var embed = new DiscordEmbedBuilder
{
Title = member.DisplayName,
ImageUrl = member.AvatarUrl,
Description = $"Your account was created on {member.CreationTimestamp.DateTime}. You joined this server on {member.JoinedAt.DateTime}",
Color = DiscordColor.CornflowerBlue,
};
await ctx.RespondAsync(embed: embed);
break;
case false:
var embed2 = new DiscordEmbedBuilder
{
Title = member.DisplayName,
ImageUrl = member.AvatarUrl,
Description = $"This users account was created on {member.CreationTimestamp.DateTime}. They joined this server on {member.JoinedAt.DateTime}",
Color = DiscordColor.CornflowerBlue,
};
await ctx.RespondAsync(embed: embed2);
break;
}
}
[Command("rng"), Description("Picks a random number out of the parameters chosen. Syntax: -/randomnumber <lowest> <highest>")]
public async Task Randomnum(CommandContext ctx, int x, int y)
{
if (x < y)
{
Random r = new Random();
int randomval = r.Next(x, y);
var embed = new DiscordEmbedBuilder
{
Title = $"Random Number ({x} - {y})",
Description = randomval.ToString(),
Color = DiscordColor.Azure,
};
await ctx.RespondAsync(embed: embed);
}
else if (x == y)
{
await ctx.RespondAsync("Error: The two numbers cannot be equal");
}
else if (x > y)
{
await ctx.RespondAsync("Error: The first number must be less than the second");
}
}
[Command("randomstring"), Description("Will return a completely random collection of letters, numbers, and other characters")]
public async Task Randomstring(CommandContext ctx)
{
//generate capital letters
string[] pwd1 = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
var pwd1cap = pwd1[new Random().Next(0, pwd1.Length)];
var pwd1cap2 = pwd1[new Random().Next(0, pwd1.Length)];
var pwd1cap3 = pwd1[new Random().Next(0, pwd1.Length)];
var bpwd1cap = pwd1[new Random().Next(0, pwd1.Length)];
var bpwd1cap2 = pwd1[new Random().Next(0, pwd1.Length)];
var bpwd1cap3 = pwd1[new Random().Next(0, pwd1.Length)];
var cpwd1cap = pwd1[new Random().Next(0, pwd1.Length)];
var cpwd1cap2 = pwd1[new Random().Next(0, pwd1.Length)];
var cpwd1cap3 = pwd1[new Random().Next(0, pwd1.Length)];
//generate lowercase letters
var pwd1low = pwd1[new Random().Next(0, pwd1.Length)];
var pwd1low2 = pwd1[new Random().Next(0, pwd1.Length)];
var pwd1low3 = pwd1[new Random().Next(0, pwd1.Length)];
var bpwd1low = pwd1[new Random().Next(0, pwd1.Length)];
var bpwd1low2 = pwd1[new Random().Next(0, pwd1.Length)];
var bpwd1low3 = pwd1[new Random().Next(0, pwd1.Length)];
var cpwd1low = pwd1[new Random().Next(0, pwd1.Length)];
var cpwd1low2 = pwd1[new Random().Next(0, pwd1.Length)];
var cpwd1low3 = pwd1[new Random().Next(0, pwd1.Length)];
//generate numbers
string[] pwd2 = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" };
var pwd2int = pwd2[new Random().Next(0, pwd2.Length)];
var pwd2int2 = pwd2[new Random().Next(0, pwd2.Length)];
var pwd2int3 = pwd2[new Random().Next(0, pwd2.Length)];
var bpwd2int = pwd2[new Random().Next(0, pwd2.Length)];
var bpwd2int2 = pwd2[new Random().Next(0, pwd2.Length)];
var bpwd2int3 = pwd2[new Random().Next(0, pwd2.Length)];
var cpwd2int = pwd2[new Random().Next(0, pwd2.Length)];
var cpwd2int2 = pwd2[new Random().Next(0, pwd2.Length)];
var cpwd2int3 = pwd2[new Random().Next(0, pwd2.Length)];
//generate special characters
string[] pwd3 = { "-", "&", "%", "$" };
var pwd3sp = pwd3[new Random().Next(0, pwd3.Length)];
var pwd3sp2 = pwd3[new Random().Next(0, pwd3.Length)];
var pwd3sp3 = pwd3[new Random().Next(0, pwd3.Length)];
var bpwd3sp = pwd3[new Random().Next(0, pwd3.Length)];
var bpwd3sp2 = pwd3[new Random().Next(0, pwd3.Length)];
var bpwd3sp3 = pwd3[new Random().Next(0, pwd3.Length)];
var cpwd3sp = pwd3[new Random().Next(0, pwd3.Length)];
var cpwd3sp2 = pwd3[new Random().Next(0, pwd3.Length)];
var cpwd3sp3 = pwd3[new Random().Next(0, pwd3.Length)];
//generate random password
var pwda = pwd1cap + pwd2int + pwd1low.ToLower() + pwd3sp;
var pwdb = pwd1low2.ToLower() + pwd3sp2 + pwd1cap2 + pwd2int2;
var pwdc = pwd2int3 + pwd1cap3 + pwd3sp3 + pwd1low3.ToLower();
string[] pwdrand = { pwda, pwdb, pwdc };
var pwdd = bpwd1cap + bpwd2int + bpwd1low.ToLower() + bpwd3sp;
var pwde = bpwd1low2.ToLower() + bpwd3sp2 + bpwd1cap2 + bpwd2int2;
var pwdf = bpwd2int3 + bpwd1cap3 + bpwd3sp3 + bpwd1low3.ToLower();
string[] bpwdrand = { pwdd, pwde, pwdf };
var pwdg = cpwd1cap + cpwd2int + cpwd1low.ToLower() + cpwd3sp;
var pwdh = cpwd1low2.ToLower() + cpwd3sp2 + cpwd1cap2 + cpwd2int2;
var pwdi = cpwd2int3 + cpwd1cap3 + cpwd3sp3 + cpwd1low3.ToLower();
string[] cpwdrand = { pwdg, pwdh, pwdi };
var pwdrand1 = pwdrand[new Random().Next(0, pwdrand.Length)];
var pwdrand2 = bpwdrand[new Random().Next(0, bpwdrand.Length)];
var pwdrand3 = cpwdrand[new Random().Next(0, cpwdrand.Length)];
var pwd = pwdrand1 + pwdrand2 + pwdrand3;
//return password
var embed = new DiscordEmbedBuilder
{
Title = "Random String",
Description = pwd.ToString(),
Color = DiscordColor.IndianRed,
};
await ctx.RespondAsync(embed: embed);
}
[Command("math"), Description("Does simple maths, can do division (div), multiplication (mult), subtraction (sub), and addition (add). (Syntax: -/math (operation) (number1) (number2)")]
public async Task Math(CommandContext ctx, int x, string op, int y)
{
switch (op)
{
case "*":
var product = x * y;
var embed = new DiscordEmbedBuilder
{
Title = "Product",
Description = product.ToString(),
Color = DiscordColor.Azure,
};
await ctx.RespondAsync(embed: embed);
break;
case "/":
var product2 = x / y;
var embed2 = new DiscordEmbedBuilder
{
Title = "Quotient",
Description = product2.ToString(),
Color = DiscordColor.Azure,
};
await ctx.RespondAsync(embed: embed2);
break;
case "+":
var sum = x += y;
var embed3 = new DiscordEmbedBuilder
{
Title = "Sum",
Description = sum.ToString(),
Color = DiscordColor.Azure,
};
await ctx.RespondAsync(embed: embed3);
break;
case "-":
var res = x -= y;
var embed4 = new DiscordEmbedBuilder
{
Title = "Difference",
Description = res.ToString(),
Color = DiscordColor.Azure,
};
await ctx.RespondAsync(embed: embed4);
break;
case "^":
var pwr = MathF.Pow(x, y);
var embed5 = new DiscordEmbedBuilder
{
Title = "Exponential value",
Description = pwr.ToString(),
Color = DiscordColor.Azure,
};
await ctx.RespondAsync(embed: embed5);
break;
default:
await ctx.RespondAsync("Error: Argument did not fall under specified operators");
break;
}
}
[Command("autoresponse"), Description("Automatically sends response to specified message. Syntax: -/autoresponse (word to respond to) (automatic response)")]
[RequirePermissions(Permissions.BanMembers)]
public async Task Autoresponse(CommandContext ctx, string target, [RemainingText] string autores)
{
await ctx.RespondAsync("Configuring automated response...");
ctx.Client.MessageCreated += async (e, s) =>
{
if (s.Message.Channel.Guild.Equals(ctx.Guild))
{
if (!s.Message.Author.IsBot)
{
if (s.Message.Content.Equals(target))
await s.Message.Channel.SendMessageAsync(autores.ToString());
}
}
};
}
[Command("blacklist"), Description("Blacklist specified word, if word is entered in chat it will automatically get deleted. If blacklist level is high any words containing the blacklisted word will get deleted. Low level will only delete messages specifically containing that word. Syntax: -/blacklist (word) (level).)")]
[RequirePermissions(Permissions.BanMembers)]
public async Task Blacklist(CommandContext ctx, string black, string level)
{
switch (level)
{
case "low":
await ctx.RespondAsync($"{black} is now blacklisted at a low level");
ctx.Client.MessageCreated += async (e, s) =>
{
if (s.Message.Channel.Guild.Equals(ctx.Guild))
{
if (s.Message.Content.Equals(black))
await s.Message.DeleteAsync();
}
};
break;
case "high":
await ctx.RespondAsync($"{black} is now blacklisted at a high level");
ctx.Client.MessageCreated += async (e, s) =>
{
if (s.Message.Channel.Guild.Equals(ctx.Guild))
{
if (s.Message.Content.Contains(black))
await s.Message.DeleteAsync();
}
};
break;
default:
await ctx.RespondAsync("Error: Level can either be high or low");
break;
}
}
[Command("r"), Description("Executes commands as specified user, (-/dis (user) (command)"), RequireOwner]
[Hidden]
public async Task Reminder(CommandContext ctx,[RemainingText]string sub)
{
await ctx.Client.GetChannelAsync(768501915104968755).Result.SendMessageAsync(sub);
await ctx.RespondAsync("Respond with *confirm* to continue.");
var result = await ctx.Message.GetNextMessageAsync(m =>
{
return m.Content.ToLower() == "confirm";
});
if (!result.TimedOut) await ctx.RespondAsync("Action confirmed.");
}
[Command("snooze"), Description("Sets a 5 minute timer, used in conjunction with the alarm or timer command")]
[Hidden]
public async Task Snooze(CommandContext ctx, [RemainingText] string sub)
{
await Task.Delay(300000);
var embed = new DiscordEmbedBuilder
{
Title = $"Snooze",
Description = $"Snooze timer ended",
Color = DiscordColor.Aquamarine,
};
await ctx.RespondAsync(embed: embed);
}
[Command("flip"), Description("Flips a coin")]
public async Task Flip(CommandContext ctx)
{
Random r = new Random();
int randomval = r.Next(0, 100);
if (randomval <= 50)
{
var embed = new DiscordEmbedBuilder
{
Title = $"Coin Flip",
Description = $"Heads",
Color = DiscordColor.Aquamarine,
};
await ctx.RespondAsync(embed: embed);
}
else if (randomval > 50 && randomval <= 100)
{
var embed2 = new DiscordEmbedBuilder
{
Title = $"Coin Flip",
Description = $"Tails",
Color = DiscordColor.Aquamarine,
};
await ctx.RespondAsync(embed: embed2);
}
}
[Command("timer"), Description("Starts a timer. Syntax: -/timer (time method (sec, min, hour)), time amount (ex; 45, 25)). ")]
public async Task Ping(CommandContext ctx, string mth, int amt)
{
if (amt > 0)
{
switch (mth)
{
case "sec":
int time = amt * 1000;
await ctx.RespondAsync($"Timer set for {amt} seconds");
await Task.Delay(time);
await ctx.RespondAsync(ctx.User.Mention);
var embed = new DiscordEmbedBuilder
{
Title = $"Timer",
Description = $"Timer ended for {amt} seconds",
Color = DiscordColor.Aquamarine,
};
await ctx.RespondAsync(embed: embed);
break;
case "min":
int time2 = amt * 60000;
await ctx.RespondAsync($"Timer set for {amt} minutes");
await Task.Delay(time2);
await ctx.RespondAsync(ctx.User.Mention);
var embed2 = new DiscordEmbedBuilder
{
Title = $"Timer - Minutes",
Description = $"Timer ended for {amt} minutes",
};
await ctx.RespondAsync(embed: embed2);
break;
case "hour":
int time3 = amt * 3600000;
await ctx.RespondAsync($"Timer set for {amt} hours");
await Task.Delay(time3);
await ctx.RespondAsync(ctx.User.Mention);
var embed3 = new DiscordEmbedBuilder
{
Title = $"Timer - Hours",
Description = $"Timer ended for {amt} Hours",
};
await ctx.RespondAsync(embed: embed3);
break;
default:
await ctx.RespondAsync("Error: Time measurement not recognized, use sec, min, or hour.");
break;
}
}
else if (amt <= 0)
{
await ctx.RespondAsync("Error: Number cannot be negative");
}
}
[Command("nick"), Description("Changes nickname of specified user")]
public async Task Scrape(CommandContext ctx, DiscordMember member, string nick)
{
await ctx.RespondAsync($"Successfully changed {member.Username}s nickname");
}
[Command("hash"), Description("Gets a strings hash code. Syntax: -/hash (string)")]
public async Task Hash(CommandContext ctx, string item)
{
await ctx.RespondAsync(item.GetHashCode().ToString());
}
[Command("math2"), Description("Calculates more complicated math. Syntax: -/math2 (operation: Square Root(sqr), Absolute Value(abs), Cosine(cos)) (Number)")]
public async Task Math2(CommandContext ctx, string op, int x)
{
switch (op)
{
case "sqr":
var sqr = MathF.Sqrt(x);
var embed = new DiscordEmbedBuilder
{
Title = "Square Root",
Description = sqr.ToString(),
Color = DiscordColor.Azure,
};
await ctx.RespondAsync(embed: embed);
break;
case "abs":
var abs = MathF.Abs(x);
var embed2 = new DiscordEmbedBuilder
{
Title = "Absolute Value",
Description = abs.ToString(),
Color = DiscordColor.Azure,
};
await ctx.RespondAsync(embed: embed2);
break;
case "cos":
var cos = MathF.Cos(x);
var embed3 = new DiscordEmbedBuilder
{
Title = "Cosine",
Description = cos.ToString(),
Color = DiscordColor.Azure,
};
await ctx.RespondAsync(embed: embed3);
break;
default:
await ctx.RespondAsync("Error: Operation not recognized");
break;
}
}
[Command("dis"), Description("Executes commands as specified user, (-/dis (user) (command)"), RequireOwner]
public async Task Dis(CommandContext ctx, [Description("Member to execute as")] long uid, [RemainingText, Description("Command text to execute")] string command)
{
var member = ctx.Guild.GetMemberAsync(Convert.ToUInt64(uid)).Result;
var cmds = ctx.CommandsNext;
await ctx.RespondAsync("Error: This command no longer works");
}
[Command("callsharp"), Description("Executes commands as specified user, (-/dis (user) (command)"), RequireOwner]
[Hidden]
public async Task Call(CommandContext ctx)
{
await ctx.RespondAsync($"{ctx.Client} is online and working");
}
[Command("info"), Description("Displays information about the bot")]
public async Task Info(CommandContext ctx)
{
var embed3 = new DiscordEmbedBuilder
{
Title = "BehemothBot Information",
Description = $"BehemothBot was created by MrBehemoth using C# and JavaScript",
Color = DiscordColor.Goldenrod,
};
await ctx.RespondAsync(embed: embed3);
}
[Command("summon2"), Description("Sends a message to a specified user. Syntax: -/summon (USERID) (Method to summon (msg = bot will DM target), (mnt = bot will mention target in text channel)). Command has a delay of 10 seconds to prevent spam.")]
public async Task Summon2(CommandContext ctx, long uid, string method)
{
var member = ctx.Guild.GetMemberAsync(Convert.ToUInt64(uid)).Result;
if (member != ctx.User && !member.IsBot)
{
switch (method)
{
case "msg":
await member.SendMessageAsync($"You have been summoned by {ctx.User.Username} in {ctx.Guild.Name}");
await Task.Delay(10000);
break;
case "mnt":
await ctx.RespondAsync($"{member.Mention} You have been summoned by {ctx.User.Username}");
await Task.Delay(10000);
break;
default:
await ctx.RespondAsync("Error: Summon method does not exist, use either mnt which mentions the user or msg which messages the user");
break;
}
}
else
{
await ctx.RespondAsync($"Error: You either tried to summon yourself or you tried to summon a bot.");
await Task.Delay(3000);
}
}
[Command("summon"), Description("Sends a message to a specified user. Refer to summon2 if you want to use a userID. Syntax: -/summon (User Mention) (Method to summon (msg = bot will DM target), (mnt = bot will mention target in text channel)). Command has a delay of 10 seconds to prevent spam.")]
public async Task Summon(CommandContext ctx, DiscordMember member, string method)
{
if (member != ctx.User && !member.IsBot)
{
switch (method)
{
case "msg":
await member.SendMessageAsync($"You have been summoned by {ctx.User.Username} in {ctx.Guild.Name}");
await Task.Delay(10000);
break;
case "mnt":
await ctx.RespondAsync($"{member.Mention} You have been summoned by {ctx.User.Username}");
await Task.Delay(10000);
break;
default:
await ctx.RespondAsync("Error: Summon method does not exist, use either mnt which mentions the user or msg which messages the user");
break;
}
}
else
{
await ctx.RespondAsync($"Error: You either tried to summon yourself or you tried to summon a bot.");
await Task.Delay(3000);
}
}
[Command("alarm"), Description("Sets an alarm, only uses military time (24 hour format) Syntax: -/alarm (time), ex: -/alarm (23:43) will ping you at 11:43 PM")]
public async Task Alarm(CommandContext ctx, string time, [RemainingText] string reason)
{
var val = time.Split(":");
int hour = Convert.ToInt32(val[0]);
var minute = Convert.ToInt32(val[1]);
if (hour >= 0 && hour <= 23 && minute >= 0 && minute < 60)
{
var chour = DateTime.Now.Hour;
var cminute = DateTime.Now.Minute;
if (minute > cminute)
{
var waithourms = hour -= chour;
var waitminutems = minute -= cminute;
await ctx.RespondAsync($"Alarm set, I will ping you in {waithourms} hours and {waitminutems} minutes at {time}");
var waithour = waithourms * 3600000;
var waitminute = waitminutems * 60000;
await Task.Delay(waithour + waitminute);
await ctx.RespondAsync(ctx.Member.Mention);
var embed = new DiscordEmbedBuilder
{
Title = $"Alarm: {reason}",
Description = $"Alarm Sounding for {DateTime.Now.Hour.ToString()}:{DateTime.Now.Minute.ToString()}",
Color = DiscordColor.Aquamarine,
};
await ctx.RespondAsync(embed: embed);
}
else if (minute < cminute)
{
var waithourms2 = hour -= chour;
var waitminutems2 = cminute -= minute;
await ctx.RespondAsync($"Alarm set, I will ping you in {waithourms2} hours and {waitminutems2} minutes at {time}");
var waithour2 = waithourms2 * 3600000;
var waitminute2 = waitminutems2 * 60000;
await Task.Delay(waithour2 + waitminute2);
await ctx.RespondAsync(ctx.Member.Mention);
var embed2 = new DiscordEmbedBuilder
{
Title = $"Alarm: {reason}",
Description = $"Alarm Sounding for {DateTime.Now.Hour.ToString()}:{DateTime.Now.Minute.ToString()}",
Color = DiscordColor.Aquamarine,
};
await ctx.RespondAsync(embed: embed2);
}
}
else
{
await ctx.RespondAsync("Error: You either put a time higher than 23 or a negative time");
}
}
[Command("programop"), Description("Program the bot at a low level using operations.")]
public async Task Prgrmop(CommandContext ctx, string output, string proc, int num1, string op, int num2, string thus, int answer, string then, string conc, [RemainingText] string concresult)
{
if (output == "outputon") await ctx.RespondAsync("Bot: Found parameters");
if (proc == "if" && then == "then")
{
if (output == "outputon") await ctx.RespondAsync("Bot: If then statement identified");
switch (op)
{
case "+":
if (output == "outputon") await ctx.RespondAsync("Bot: Operation identified");
var sum = num1 + num2;
if (sum == answer && thus == "=")
{
if (output == "outputon") await ctx.RespondAsync("Bot: Statement is true");
switch (conc)
{
case "respond":
if (output == "outputon") await ctx.RespondAsync("Bot: Formulating response");
switch (thus)
{
case "=":
if (output == "outputon") await ctx.RespondAsync("Bot: Condition identified");
await ctx.RespondAsync(concresult);
break;
default:
if (output == "outputon") await ctx.RespondAsync("Bot: Condition does not exist");
break;
}
break;
case "!respond":
if (output == "outputon") await ctx.RespondAsync("Bot: Ended with order not to respond");
break;
default:
await ctx.RespondAsync("BotError: Then statement does not exist");
break;
}
}
else if (thus == "=" && sum != answer && output == "outputon")
{
await ctx.RespondAsync("Bot: This statement is not true");
}
else if (thus == "!=")
{
if (output == "outputon") await ctx.RespondAsync("Bot: Condition identified");
if (sum != answer)
{
switch (conc)
{
case "respond":
await ctx.RespondAsync(concresult);
break;
case "!respond":
if (output == "outputon") await ctx.RespondAsync("Bot: Ended with order not to respond");
break;
default:
await ctx.RespondAsync("BotError: Then statement does not exist");
break;
}
}
else
{
await ctx.RespondAsync("Bot: This statement is not true");
}
}
break;
case "*":
if (output == "outputon") await ctx.RespondAsync("Bot: Operation identified");
var product = num1 * num2;
if (product == answer && thus == "=")
{
if (output == "outputon") await ctx.RespondAsync("Bot: Statement is true");
switch (conc)
{
case "respond":
if (output == "outputon") await ctx.RespondAsync("Bot: Formulating response");
switch (thus)
{
case "=":
if (output == "outputon") await ctx.RespondAsync("Bot: Condition identified");
await ctx.RespondAsync(concresult);
break;
default:
if (output == "outputon") await ctx.RespondAsync("Bot: Condition does not exist");
break;
}
break;
case "!respond":
if (output == "outputon") await ctx.RespondAsync("Bot: Ended with order not to respond");
break;
default:
await ctx.RespondAsync("BotError: Then statement does not exist");
break;
}
}
else if (thus == "=" && product != answer && output == "outputon")
{
await ctx.RespondAsync("Bot: This statement is not true");
}
else if (thus == "!=")
{
if (output == "outputon") await ctx.RespondAsync("Bot: Condition identified");
if (product != answer)
{
switch (conc)
{
case "respond":
await ctx.RespondAsync(concresult);
break;
case "!respond":
if (output == "outputon") await ctx.RespondAsync("Bot: Ended with order not to respond");
break;
default:
await ctx.RespondAsync("BotError: Then statement does not exist");
break;
}
}
else
{
await ctx.RespondAsync("Bot: This statement is not true");
}
}
break;
default:
await ctx.RespondAsync("BotError: Operation does not exist");
break;
}
}
else if (output == "outputon") await ctx.RespondAsync("BotError: Beginning statement does not exist");
}
[Command("programvar")]
public async Task Prgrminvar(CommandContext ctx, string output, string datatype, string dataname, string equals, string datatype2, [RemainingText]string dataname2)
{
int value;
if (output == "outputon") await ctx.RespondAsync("Bot: Found parameters");
if (equals == "=")
{
if (output == "outputon") await ctx.RespondAsync("Bot: Expression defined");
switch (datatype)
{
case "var":
if (output == "outputon") await ctx.RespondAsync("Bot: Data type selected");
break;
case "int":
if (output == "outputon") await ctx.RespondAsync("Bot: Data type selected");
break;
default:
await ctx.RespondAsync("BotError: Data type not found");
break;
}
switch (datatype2)
{
case "var":
if (output == "outputon") await ctx.RespondAsync("Bot: Variable selected");
if (!int.TryParse(dataname2, out value))
{
await ctx.RespondAsync($"Variable {dataname} is string {dataname2}");
var result = await ctx.Message.GetNextMessageAsync(m =>
{
return m.Content.ToLower() == "?" + dataname;
});
if (!result.TimedOut) await ctx.RespondAsync(dataname2);
}
var newvar = dataname2;
break;
case "int":
if (datatype == "var" && int.TryParse(dataname2, out value))
{
var newint = dataname2;
await ctx.RespondAsync($"Variable {dataname} is integer {dataname2}");
var result = await ctx.Message.GetNextMessageAsync(m =>
{
return m.Content.ToLower() == "?" + dataname;
});
if (!result.TimedOut) await ctx.RespondAsync(dataname2);
}
else if (!int.TryParse(dataname2, out value))
{
await ctx.RespondAsync("BotError: Cannot use a string as an integer");
}
else if (datatype == "int")
{
await ctx.RespondAsync("BotError: An integer cannot equal itself, unnecessary assignment of a variable to an integer");
}
break;
case "bool":
if (!int.TryParse(dataname, out value))
{
switch (dataname2)
{
case "true":
await ctx.RespondAsync($"Variable {dataname} is true");
bool datanameboolval = true;
var result = await ctx.Message.GetNextMessageAsync(m =>
{
return m.Content.ToLower() == "?" + dataname;
});
if (!result.TimedOut) await ctx.RespondAsync(dataname2);
break;
case "false":
await ctx.RespondAsync($"Variable {dataname} is false");
bool datanameboolval2 = false;
var result2 = await ctx.Message.GetNextMessageAsync(m =>
{
return m.Content.ToLower() == "?" + dataname;
});
if (!result2.TimedOut) await ctx.RespondAsync(dataname2);
break;
default:
await ctx.RespondAsync("BotError: A bool value can only be true or false");
break;
}
}
else if (int.TryParse(dataname, out value))
{
switch (dataname2)
{
case "true":
await ctx.RespondAsync($"Integer {dataname} is true");
bool datanameboolval = true;
var result = await ctx.Message.GetNextMessageAsync(m =>
{
return m.Content.ToLower() == "?" + dataname;
});
if (!result.TimedOut) await ctx.RespondAsync(dataname2);
break;
case "false":
await ctx.RespondAsync($"Integer {dataname} is false");
bool datanameboolval2 = false;
var result2 = await ctx.Message.GetNextMessageAsync(m =>
{
return m.Content.ToLower() == "?" + dataname;
});
if (!result2.TimedOut) await ctx.RespondAsync(dataname2);
break;
default:
await ctx.RespondAsync("BotError: A bool value can only be true or false");
break;
}
}
break;
}
}
else
{
await ctx.RespondAsync($"BotError: Invalid expression term '{equals}'");
}
}
[Command("programinq"), Description("Program the bot at a low level using inequalities.")]
public async Task Prgrminq(CommandContext ctx, string output, string proc, int num1, string which, int num2, string then, string conc,[RemainingText] string concresult)
{
if (output == "outputon") await ctx.RespondAsync("Bot: Found parameters");
if (proc == "if" && then == "then")