Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.42 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Discord.Commands;
  5. using Discord.WebSocket;
  6. using System.Threading.Tasks;
  7. using Discord;
  8. using System.Linq;
  9. using System.IO;
  10. using System.Net.Mail;
  11. using System.Diagnostics;
  12. using System.Net.Http;
  13. using System.Xml.Serialization;
  14. using System.Timers;
  15. using Google.API;
  16. using Google.Apis.Translate;
  17. using Google.API.Translate;
  18. using Microsoft.CognitiveServices.Speech;
  19.  
  20. namespace DiscordBot.Commands
  21. {
  22.  
  23. public class DiscordCommands : ModuleBase<SocketCommandContext>
  24. {
  25. public static IUserMessage moonMessage;
  26.  
  27.  
  28. private readonly string _playerDetailsUrl = "http://steamcommunity.com/id/{0}/?xml=1";
  29.  
  30. private string username;
  31.  
  32. [Command("hello")]
  33. public async Task HelloAsync()
  34. {
  35. await ReplyAsync("Hello there!");
  36. }
  37.  
  38. [Command("miskraam")]
  39. public async Task MiskraamAsync(IGuildUser user)
  40. {
  41. await ReplyAsync($"{user.Mention} miskraam");
  42. await Task.Delay(450);
  43. await MiskraamAsync(user);
  44. }
  45.  
  46. [Command("data")]
  47. public async Task DataAsync()
  48. {
  49. Program.prefix = (File.ReadAllText(@"D:\Program Files (x86)\DiscordBot\Prefix.txt"));
  50. List<string> newCoins = new List<string>();
  51. newCoins.AddRange(File.ReadLines(@"D:\Program Files (x86)\DiscordBot\Coins.txt"));
  52. Program.coins = Array.ConvertAll(newCoins.ToArray(), int.Parse).ToList();
  53.  
  54. Program.users.AddRange(File.ReadLines(@"D:\Program Files (x86)\DiscordBot\Users.txt"));
  55. int i = Array.IndexOf(Program.users.ToArray(), Context.User.ToString());
  56. var strings = (File.ReadLines(@"D:\Program Files (x86)\DiscordBot\TimesLeft.txt"));
  57. List<DateTime> dates = strings.Select(date => DateTime.Parse(date)).ToList();
  58. Program.timesLeft.AddRange(dates);
  59.  
  60.  
  61. foreach (string user in Program.users)
  62. {
  63. Program.betAmount.Add(50);
  64. }
  65.  
  66. await ReplyAsync($"All data loaded, use prefix `{Program.prefix}` :thumbsup:");
  67. }
  68.  
  69. [Command("say")]
  70. public async Task SayAsync(string message)
  71. {
  72. await Context.Message.DeleteAsync();
  73. await ReplyAsync(message);
  74. }
  75.  
  76. [Command("moon")]
  77. public async Task MoonAsync(int times)
  78. {
  79. if (times < 5)
  80. {
  81. int timesLeft = times;
  82. timesLeft--;
  83.  
  84. IUserMessage message = moonMessage;
  85. if (message == null)
  86. {
  87. message = await Context.Channel.SendMessageAsync(":new_moon:");
  88. }
  89.  
  90. await Task.Delay(1000);
  91. await message.ModifyAsync(msg => msg.Content = ":waning_crescent_moon:");
  92.  
  93. await Task.Delay(1000);
  94. await message.ModifyAsync(msg => msg.Content = ":last_quarter_moon:");
  95.  
  96. await Task.Delay(1000);
  97. await message.ModifyAsync(msg => msg.Content = ":waning_gibbous_moon:");
  98.  
  99. await Task.Delay(1000);
  100. await message.ModifyAsync(msg => msg.Content = ":full_moon:");
  101.  
  102. await Task.Delay(1000);
  103. await message.ModifyAsync(msg => msg.Content = ":waxing_gibbous_moon:");
  104.  
  105. await Task.Delay(1000);
  106. await message.ModifyAsync(msg => msg.Content = ":first_quarter_moon:");
  107.  
  108. await Task.Delay(1000);
  109. await message.ModifyAsync(msg => msg.Content = ":waxing_crescent_moon:");
  110.  
  111. await Task.Delay(1000);
  112. await message.ModifyAsync(msg => msg.Content = ":new_moon:");
  113.  
  114. moonMessage = message;
  115. if (timesLeft > 0)
  116. {
  117. await MoonAsync(timesLeft);
  118. }else
  119. {
  120. moonMessage = null;
  121. }
  122. }else
  123. {
  124. await ReplyAsync("Enter a number under 5");
  125. }
  126. }
  127.  
  128. [Command("sicko")]
  129. public async Task Sicko()
  130. {
  131. var message = await Context.Channel.SendMessageAsync("https://i.redd.it/e5za9yb75myz.gif");
  132. }
  133.  
  134. [Command("setgame")]
  135. public async Task HelloAsync(string game)
  136. {
  137. await Program.client.SetGameAsync(game);
  138. await ReplyAsync("Changed game status to `" + game + "` :thumbsup:");
  139. }
  140.  
  141. [Command("freecoins")]
  142. public async Task FreeCoinsAsync()
  143. {
  144. int i = Array.IndexOf(Program.users.ToArray(), Context.User.ToString());
  145. var timeLeft = (Program.timesLeft[i] - DateTime.Now);
  146. var hoursLeft = 12 - timeLeft.Hours;
  147. if (hoursLeft <= 0)
  148. {
  149. Program.coins[i] += 500;
  150. await ReplyAsync($"{Context.User.Mention} You have been given `500 coins` :thumbsup:");
  151. }
  152. else if (hoursLeft > 0 && hoursLeft < 1)
  153. {
  154. await ReplyAsync($"You need to wait a couple more minutes to do this.");
  155. }
  156. else
  157. {
  158. await ReplyAsync($"You need to wait {hoursLeft} more hours to do this.");
  159. }
  160. }
  161.  
  162. [Command("ping")]
  163. public async Task PingAsync()
  164. {
  165. var ping = Program.client.Latency;
  166.  
  167. Stopwatch latency = new Stopwatch();
  168. latency.Start();
  169.  
  170. if (ping < 200)
  171. {
  172. await ReplyAsync($"My current latency with the gateway server is `{Program.client.Latency}` :white_check_mark: ");
  173. }
  174. else if (ping < 500)
  175. {
  176. await ReplyAsync($"My current latency with the gateway server is `{Program.client.Latency}` :ok: ");
  177. }else if(ping < 1)
  178. {
  179. await ReplyAsync($"My current latency with the gateway server is `{Program.client.Latency}` :warning:");
  180. }else
  181. {
  182. await ReplyAsync($"My current latency with the gateway server is `{Program.client.Latency}` :sos:");
  183. }
  184.  
  185. latency.Stop();
  186.  
  187. if (latency.ElapsedMilliseconds < 150)
  188. {
  189. await ReplyAsync($"Script latency of `{latency.ElapsedMilliseconds}` :white_check_mark: ");
  190. }
  191. else if (latency.ElapsedMilliseconds < 250)
  192. {
  193. await ReplyAsync($"Script latency of `{latency.ElapsedMilliseconds}` :ok: ");
  194. }
  195. else if (latency.ElapsedMilliseconds < 350)
  196. {
  197. await ReplyAsync($"Script latency of `{latency.ElapsedMilliseconds}` :warning:");
  198. }
  199. else
  200. {
  201. await ReplyAsync($"Script latency of `{latency.ElapsedMilliseconds}` :sos:");
  202. }
  203. }
  204.  
  205. [Command("help"),]
  206. public async Task HelpAsync()
  207. {
  208. await ReplyAsync($"**Prefix** *`{Program.prefix}`* \n \n**Public Commands:** \n *`{Program.prefix}rollunder <2-98>`* Generate a random number, if under the given number, you win coins " +
  209. $"\n *`{Program.prefix}betamount <amount>`* Sets your bet amount to the given value \n *`{Program.prefix}roulette <color>`* Play roulette and guess the color to win coins \n *`{Program.prefix}suggest <command> <description> `* Suggest a command to the developer \n \n" +
  210. $"\n **Administrator Commands:** \n *`{Program.prefix}clear <amount>`* Removes the given amount of messages \n *`{Program.prefix}mute <user> <seconds>`* Mutes the user for the given amount of seconds" +
  211. $"\n *`{Program.prefix}addrole <name> <color>`* Add a role to the server \n *`{Program.prefix}removerole <name> `* Remove a role from the server");
  212. }
  213.  
  214. [Command("steamprofile")]
  215. [RequireBotPermission(GuildPermission.ManageMessages)]
  216. public async Task SteamProfileAsync(string ID)
  217. {
  218. var idarray = ID.Split(":");
  219. long convertedTo64Bit = System.Convert.ToInt64(idarray[2]) * 2;
  220. convertedTo64Bit += 76561197960265728;
  221. convertedTo64Bit += System.Convert.ToInt64(idarray[1]);
  222. var link = (@"http://steamcommunity.com/profiles/" + convertedTo64Bit);
  223. await ReplyAsync($"Steam user profile: {link}");
  224. }
  225.  
  226. [Command("steamid64")]
  227. [RequireBotPermission(GuildPermission.ManageMessages)]
  228. public async Task ID64Async(string ID)
  229. {
  230. var idarray = ID.Split(":");
  231. long convertedTo64Bit = System.Convert.ToInt64(idarray[2]) * 2;
  232. convertedTo64Bit += 76561197960265728;
  233. convertedTo64Bit += System.Convert.ToInt64(idarray[1]);
  234. await ReplyAsync($"Steam user ID64: `{convertedTo64Bit}`");
  235. }
  236.  
  237. private string NormalizeUsername(string name)
  238. {
  239. return name.Contains("http://") ? name : string.Format(_playerDetailsUrl, name);
  240. }
  241.  
  242. [Command("clear")]
  243. [RequireBotPermission(GuildPermission.ManageMessages)]
  244. [RequireUserPermission(GuildPermission.ManageChannels)]
  245. public async Task DelMesAsync(int delnum)
  246. {
  247. var items = await Context.Channel.GetMessagesAsync(delnum + 1).Flatten();
  248. await Context.Channel.DeleteMessagesAsync(items);
  249. var message = await ReplyAsync("Removed " + delnum.ToString() + " messages <:nyan:510907023928459274>");
  250. await Task.Delay(5000);
  251. await message.DeleteAsync();
  252. }
  253.  
  254. [Command("despacito")]
  255. [RequireBotPermission(GuildPermission.ManageMessages)]
  256. public async Task DespacitoAsync()
  257. {
  258. await ReplyAsync("bokito bokito");
  259. }
  260.  
  261. [Command("mute")]
  262. [RequireBotPermission(GuildPermission.ManageMessages)]
  263. [RequireUserPermission(GuildPermission.BanMembers)]
  264. public async Task MuteAsync(IGuildUser user, int seconds)
  265. {
  266. var role = Context.Guild.Roles.FirstOrDefault(x => x.Name == "Muted");
  267. await (user as IGuildUser).AddRoleAsync(role);
  268. await ReplyAsync("Muted " + user.Mention + " for `" + seconds + " seconds`");
  269.  
  270. await Task.Delay(seconds * 1000);
  271. await (user as IGuildUser).RemoveRoleAsync(role);
  272. }
  273.  
  274. [Command("addrole")]
  275. [RequireBotPermission(GuildPermission.ManageMessages)]
  276. [RequireUserPermission(GuildPermission.BanMembers)]
  277. public async Task AddRoleAsync(string name, string color)
  278. {
  279. Discord.Color roleColor = new Discord.Color((UInt32)(System.Drawing.Color.FromName(color).ToArgb()));
  280.  
  281. if (color == "blue")
  282. {
  283. roleColor = Color.Blue;
  284. }
  285. else if (color == "red")
  286. {
  287. roleColor = Color.Red;
  288. }
  289. else if (color == "green")
  290. {
  291. roleColor = Color.Green;
  292. }
  293. else if (color == "purple")
  294. {
  295. roleColor = Color.Purple;
  296. }
  297. else if (color == "darkblue")
  298. {
  299. roleColor = Color.DarkBlue;
  300. }
  301.  
  302. var role = await Context.Guild.CreateRoleAsync(name, null, roleColor, false, null);
  303. await ReplyAsync("Added role `" + name + "` to the server :thumbsup:");
  304. }
  305.  
  306.  
  307. [Command("removerole")]
  308. [RequireBotPermission(GuildPermission.ManageMessages)]
  309. [RequireUserPermission(GuildPermission.BanMembers)]
  310. public async Task DeleteRoleAsync(SocketRole role)
  311. {
  312. var message = await ReplyAsync(@"\" + role.Mention);
  313. await message.DeleteAsync();
  314. string messageText = message.ToString();
  315. messageText = messageText.Replace("<", "");
  316. messageText = messageText.Replace(">", "");
  317. messageText = messageText.Replace("@", "");
  318. messageText = messageText.Replace("&", "");
  319. messageText = messageText.Replace(@"\", "");
  320. ulong ulongID = ulong.Parse(messageText);
  321. await Context.Guild.GetRole(ulongID).DeleteAsync();
  322. await ReplyAsync("Removed role `" + Context.Guild.GetRole(ulongID) + "` from the server :thumbsup:");
  323. }
  324.  
  325. [Command("unmute")]
  326. [RequireBotPermission(GuildPermission.BanMembers)]
  327. [RequireUserPermission(GuildPermission.BanMembers)]
  328. public async Task UnmuteAsync(IGuildUser user)
  329. {
  330. var role = Context.Guild.Roles.FirstOrDefault(x => x.Name == "Muted");
  331. await (user as IGuildUser).RemoveRoleAsync(role);
  332. await ReplyAsync("Unmuted " + user.Mention);
  333. }
  334.  
  335. [Command("ban")]
  336. [RequireBotPermission(GuildPermission.BanMembers)]
  337. [RequireUserPermission(GuildPermission.BanMembers)]
  338. public async Task BanAsync(IGuildUser user)
  339. {
  340. await Context.Guild.AddBanAsync(user);
  341. }
  342.  
  343. [Command("lock")]
  344. [RequireBotPermission(GuildPermission.BanMembers)]
  345. [RequireUserPermission(GuildPermission.BanMembers)]
  346. public async Task LockAsync(IGuildUser user, int seconds)
  347. {
  348. var role = Context.Guild.Roles.FirstOrDefault(x => x.Name == "locked");
  349. await (user as IGuildUser).AddRoleAsync(role);
  350. await ReplyAsync("Locked " + user.Mention + " for `" + seconds + " seconds`");
  351.  
  352. await Task.Delay(seconds * 1000);
  353. await (user as IGuildUser).RemoveRoleAsync(role);
  354. }
  355.  
  356. [Command("unlock")]
  357. [RequireBotPermission(GuildPermission.BanMembers)]
  358. [RequireUserPermission(GuildPermission.BanMembers)]
  359. public async Task UnlockAsync(IGuildUser user)
  360. {
  361. var role = Context.Guild.Roles.FirstOrDefault(x => x.Name == "locked");
  362. await (user as IGuildUser).RemoveRoleAsync(role);
  363. await ReplyAsync("Unlocked " + user.Mention);
  364. }
  365.  
  366. [Command("kick")]
  367. [RequireBotPermission(GuildPermission.KickMembers)]
  368. [RequireUserPermission(GuildPermission.BanMembers)]
  369. public async Task KickAsync(IGuildUser user)
  370. {
  371. await ReplyAsync("Kicked " + user.Mention + " from the server :wave: :thumbsup:");
  372. await user.KickAsync();
  373. }
  374.  
  375. [Command("suggest")]
  376. public async Task SuggestAsync(string command, string description)
  377. {
  378. SmtpClient client = new SmtpClient();
  379. client.Port = 587;
  380. client.Host = "smtp.gmail.com";
  381. client.EnableSsl = true;
  382. client.Timeout = 10000;
  383. client.DeliveryMethod = SmtpDeliveryMethod.Network;
  384. client.UseDefaultCredentials = false;
  385. client.Credentials = new System.Net.NetworkCredential("larsvcroonenburg@gmail.com", "Valuegames2002");
  386.  
  387. MailMessage mail = new MailMessage("larsvcroonenburg@gmail.com", "larsvcroonenburg@gmail.com", Context.User + " suggested " + command, Context.User + " suggested to add " + command + " with description: " + description);
  388. mail.BodyEncoding = UTF8Encoding.UTF8;
  389. mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
  390.  
  391. client.Send(mail);
  392. await ReplyAsync($"{Context.User.Mention} Suggested command `" + command + "` :thumbsup:");
  393. }
  394.  
  395. [Command("rollunder")]
  396. public async Task RollAsync(int chance)
  397. {
  398. if (chance > 1 && chance < 98)
  399. {
  400. int i = Array.IndexOf(Program.users.ToArray(), Context.User.ToString());
  401.  
  402. Random random = new Random();
  403. int roll = random.Next(0, 100);
  404.  
  405. if (roll < chance && Program.coins[i] >= Program.betAmount[i])
  406. {
  407. Program.coins[i] -= Program.betAmount[i];
  408. await ReplyAsync($"{Context.User.Mention} `-" + Program.betAmount[i].ToString() + "` coins");
  409.  
  410. float floatChance = chance * 1.0f;
  411. float wonCoins = Program.betAmount[i] * (100 / floatChance);
  412. Program.coins[i] += (int)wonCoins;
  413. await ReplyAsync($"{Context.User.Mention} It rolled `" + roll.ToString() + "` and you won `" + ((int)wonCoins).ToString() + "` coins :white_check_mark:");
  414. File.WriteAllLines(@"D:\Program Files (x86)\DiscordBot\Coins.txt", Program.coins.Select(x => x.ToString()).ToArray());
  415. }
  416. else if (Program.coins[i] >= Program.betAmount[i])
  417. {
  418. Program.coins[i] -= Program.betAmount[i];
  419. await ReplyAsync($"{Context.User.Mention} `-" + Program.betAmount[i].ToString() + "` coins");
  420. await ReplyAsync($"{Context.User.Mention} It rolled `" + roll.ToString() + "` and you lost :x:");
  421. File.WriteAllLines(@"D:\Program Files (x86)\DiscordBot\Coins.txt", Program.coins.Select(x => x.ToString()).ToArray());
  422. }
  423. else if (Program.coins[i] < Program.betAmount[i])
  424. {
  425. await ReplyAsync($"{Context.User.Mention} Not enough coins to do this, change your bet amount with .betamount <number>");
  426. }
  427. }
  428. else
  429. {
  430. await ReplyAsync($"{Context.User.Mention} Enter a valid number between 1 and 98");
  431. }
  432. }
  433.  
  434. [Command("roulette")]
  435. public async Task AmountAsync(string color)
  436. {
  437.  
  438. if (color == "red" || color == "blue" || color == "black")
  439. {
  440. int i = Array.IndexOf(Program.users.ToArray(), Context.User.ToString());
  441.  
  442. Random random = new Random();
  443. float roll = random.Next(0, 100);
  444.  
  445. string rollColor = "color";
  446. int wonCoins = new int();
  447.  
  448. if (roll < 7)
  449. {
  450. rollColor = "blue";
  451. wonCoins = Program.betAmount[i] * 14;
  452. }
  453. else if (roll > 7 && roll <= 53.5)
  454. {
  455. rollColor = "black";
  456. wonCoins = Program.betAmount[i] * 2;
  457. }
  458. else if (roll > 53.5)
  459. {
  460. rollColor = "red";
  461. wonCoins = Program.betAmount[i] * 2;
  462. }
  463.  
  464. if (Program.coins[i] >= Program.betAmount[i])
  465. {
  466. Program.coins[i] -= Program.betAmount[i];
  467. await ReplyAsync($"{Context.User.Mention} `-" + Program.betAmount[i].ToString() + "` coins");
  468.  
  469. if (rollColor == color)
  470. {
  471. Program.coins[i] += wonCoins;
  472. if (rollColor == "red")
  473. {
  474. await ReplyAsync($"{Context.User.Mention} It rolled :red_circle: red :red_circle: and you won `" + wonCoins.ToString() + "coins`");
  475. }
  476. else if (rollColor == "black")
  477. {
  478. await ReplyAsync($"{Context.User.Mention} It rolled :black_circle: black :black_circle: and you won `" + wonCoins.ToString() + "coins`");
  479. }
  480. else if (rollColor == "blue")
  481. {
  482. await ReplyAsync($"{Context.User.Mention} It rolled :large_blue_circle: blue :large_blue_circle: and you won `" + wonCoins.ToString() + "coins`");
  483. }
  484. }
  485. else
  486. {
  487. if (rollColor == "red")
  488. {
  489. await ReplyAsync($"{Context.User.Mention} It rolled :red_circle: red :red_circle: and you lost");
  490. }
  491. else if (rollColor == "black")
  492. {
  493. await ReplyAsync($"{Context.User.Mention} It rolled :black_circle: black :black_circle: and you lost");
  494. }
  495. else if (rollColor == "blue")
  496. {
  497. await ReplyAsync($"{Context.User.Mention} It rolled :large_blue_circle: blue :large_blue_circle: and you lost");
  498. }
  499. }
  500. File.WriteAllLines(@"D:\Program Files (x86)\DiscordBot\Coins.txt", Program.coins.Select(x => x.ToString()).ToArray());
  501. }
  502. else if (Program.coins[i] < Program.betAmount[i])
  503. {
  504. await ReplyAsync($"{Context.User.Mention} Not enough coins to do this, change your bet amount with .betamount <number>");
  505. }
  506. }
  507. else
  508. {
  509. await ReplyAsync($"{Context.User.Mention} Enter a valid color (red (46.5%), black (46.5%), blue(7%))");
  510. }
  511. }
  512.  
  513. [Command("betamount")]
  514. public async Task AmountAsync(int amount)
  515. {
  516. if (amount > 0)
  517. {
  518. if (Program.betAmount.ToArray().Length < Program.users.ToArray().Length)
  519. {
  520. Program.betAmount.Add(amount);
  521. }
  522. int i = Array.IndexOf(Program.users.ToArray(), Context.User.ToString());
  523. Program.betAmount[i] = amount;
  524. await ReplyAsync($"{Context.User.Mention} Bet amount changed to `" + amount.ToString() + "` :thumbsup:");
  525. }
  526. else
  527. {
  528. await ReplyAsync("Enter a bet amount higher than 0");
  529. }
  530. }
  531.  
  532. [Command("id")]
  533. public async Task IDAsync()
  534. {
  535. int i = Array.IndexOf(Program.users.ToArray(), Context.User.ToString());
  536. await ReplyAsync($"{Context.User.Mention} Your user ID is " + i.ToString());
  537. }
  538.  
  539. [Command("add")]
  540. public async Task AddQAsync(string question)
  541. {
  542. Program.questions.Add(question);
  543. return;
  544. }
  545.  
  546. [Command("coins")]
  547. public async Task CoinsAsync()
  548. {
  549. int i = Array.IndexOf(Program.users.ToArray(), Context.User.ToString());
  550.  
  551. await ReplyAsync($"{Context.User.Mention} You have `" + Program.coins[i].ToString() + "` coins");
  552. }
  553.  
  554. [Command("shop")]
  555. public async Task ShopAsync()
  556. {
  557. await ReplyAsync("Roles: \n 1. Special *`2.000 coins`* \n 2. DJ Role *`10.000 coins`* \n 3. Moderator *`50.000 coins`* \n \n Commands: ");
  558. }
  559.  
  560. [Command("buy")]
  561. public async Task BuyAsync(int id)
  562. {
  563. int i = Array.IndexOf(Program.users.ToArray(), Context.User.ToString());
  564. if (id == 1)
  565. {
  566. if (Program.coins[i] >= 2000)
  567. {
  568. Program.coins[i] -= 2000;
  569. var role = Context.Guild.Roles.FirstOrDefault(x => x.Name == "Special");
  570. await (Context.User as IGuildUser).AddRoleAsync(role);
  571. await ReplyAsync($"{Context.User.Mention} Successfully received role Special for *`2.000 coins`*");
  572. }
  573. else
  574. {
  575. await ReplyAsync($"{Context.User.Mention} Not enough coins to buy this");
  576. }
  577. }
  578. else if (id == 2)
  579. {
  580. await ReplyAsync($"{Context.User.Mention} This role is not available");
  581. }
  582. else if (id == 3)
  583. {
  584. await ReplyAsync($"{Context.User.Mention} This role is not available");
  585. }
  586.  
  587. }
  588.  
  589. [Command("createuser")]
  590. public async Task GiveCoinsAsync()
  591. {
  592. if (!Program.users.Contains(Context.User.ToString()))
  593. {
  594. Program.users.Add(Context.User.ToString());
  595. File.WriteAllLines(@"D:\Program Files (x86)\DiscordBot\Users.txt", Program.users.ToArray());
  596. Program.coins.Add(500);
  597. File.WriteAllLines(@"D:\Program Files (x86)\DiscordBot\Coins.txt", Program.coins.Select(x => x.ToString()).ToArray());
  598. Program.betAmount.Add(50);
  599. Program.timesLeft.Add(DateTime.Now);
  600. File.WriteAllLines(@"D:\Program Files (x86)\DiscordBot\TimesLeft.txt", Program.timesLeft.Select(x => x.ToString()).ToArray());
  601. await ReplyAsync($"{Context.User.Mention} User created and you received `500 coins` :thumbsup:");
  602. }
  603. else
  604. {
  605. await ReplyAsync($"{Context.User.Mention} You are already registered as user");
  606. }
  607. }
  608.  
  609. [Command("givecoins")]
  610. [RequireUserPermission(GuildPermission.BanMembers)]
  611. public async Task GiveCoinsAsync(SocketGuildUser user, int amount)
  612. {
  613. int i = Array.IndexOf(Program.users.ToArray(), user.ToString());
  614. Program.coins[i] += amount;
  615. await ReplyAsync($"{user.Mention} has been given `" + amount.ToString() + " coins`");
  616. File.WriteAllLines(@"D:\Program Files (x86)\DiscordBot\Coins.txt", Program.coins.Select(x => x.ToString()).ToArray());
  617. }
  618.  
  619. [Command("give")]
  620. public async Task GiveAsync(SocketGuildUser user, int amount)
  621. {
  622. int e = Array.IndexOf(Program.users.ToArray(), Context.User.ToString());
  623. Program.coins[e] -= amount;
  624. int i = Array.IndexOf(Program.users.ToArray(), user.ToString());
  625. Program.coins[i] += amount;
  626. File.WriteAllLines(@"D:\Program Files (x86)\DiscordBot\Coins.txt", Program.coins.Select(x => x.ToString()).ToArray());
  627. await ReplyAsync($"{Context.User.Mention} has given `" + amount.ToString() + " coins` to " + user.Mention);
  628. }
  629.  
  630. [Command("coinflip")]
  631. public async Task CoinFlipAsync(int amount)
  632. {
  633. int i = Array.IndexOf(Program.users.ToArray(), Context.User.ToString());
  634. if (Program.coins[i] >= Program.flipAmount && Program.flipAmount > 0 || Program.coins[i] >= amount && Program.flipAmount == 0)
  635. {
  636. if (!Program.coinFlipUsers.Contains(Context.User.ToString()))
  637. {
  638.  
  639. if (Program.coinFlip <= 2)
  640. {
  641. if (amount == Program.flipAmount && Program.coinFlip > 0 || Program.coinFlip == 0 && amount > 0)
  642. {
  643. Program.flipAmount = amount;
  644. Program.coins[i] -= amount;
  645. File.WriteAllLines(@"D:\Program Files (x86)\DiscordBot\Coins.txt", Program.coins.Select(x => x.ToString()).ToArray());
  646. Program.coinFlip++;
  647. Program.coinFlipUsers.Add(Context.User.ToString());
  648. await ReplyAsync($"{Context.User.Mention} has joined the coinflip with `" + amount.ToString() + " coins` (" + Program.coinFlip.ToString() + "/2)");
  649. if (Program.coinFlip == 2)
  650. {
  651. Random random = new Random();
  652. float roll = random.Next(0, 100);
  653.  
  654. if (roll < 50)
  655. {
  656. int w = Array.IndexOf(Program.users.ToArray(), Program.coinFlipUsers[0]);
  657. Program.coins[w] += Program.flipAmount * 2;
  658. await ReplyAsync($"{Program.coinFlipUsers[0]} has won the coinflip and won `" + Program.flipAmount.ToString() + " coins`");
  659. File.WriteAllLines(@"D:\Program Files (x86)\DiscordBot\Coins.txt", Program.coins.Select(x => x.ToString()).ToArray());
  660. }
  661. else
  662. {
  663. int w = Array.IndexOf(Program.users.ToArray(), Program.coinFlipUsers[1]);
  664. Program.coins[w] += Program.flipAmount * 2;
  665. await ReplyAsync($"{Program.coinFlipUsers[1]} has won the coinflip and won `" + Program.flipAmount.ToString() + " coins`");
  666. File.WriteAllLines(@"D:\Program Files (x86)\DiscordBot\Coins.txt", Program.coins.Select(x => x.ToString()).ToArray());
  667. }
  668.  
  669. Program.coinFlipUsers.Clear();
  670. Program.flipAmount = 0;
  671. Program.coinFlip = 0;
  672. }
  673. }
  674. else if (amount != Program.flipAmount && Program.coinFlip > 0)
  675. {
  676. await ReplyAsync($"{Context.User.Mention} Enter the coinflip with the same amount");
  677. }
  678. else
  679. {
  680. await ReplyAsync($"{Context.User.Mention} Enter a number greater than 0");
  681. }
  682. }
  683. else
  684. {
  685. await ReplyAsync($"{Context.User.Mention} Wait for the next coinflip");
  686. }
  687. }
  688. else
  689. {
  690. await ReplyAsync($"{Context.User.Mention} You already joined the coinflip");
  691. }
  692. }
  693. else
  694. {
  695. await ReplyAsync($"{Context.User.Mention} Not enough coins");
  696. }
  697. }
  698.  
  699.  
  700. [Command("stink")]
  701. public async Task StinkAsync(SocketGuildUser user)
  702. {
  703. await ReplyAsync($"{user.Mention} is een stink joch");
  704. }
  705.  
  706. [Command("prefix")]
  707. [RequireUserPermission(GuildPermission.BanMembers)]
  708. public async Task StinkAsync(string prefix)
  709. {
  710. await ReplyAsync($"Prefix changed to `{prefix}`");
  711. Program.prefix = prefix;
  712. File.WriteAllText(@"D:\Program Files (x86)\DiscordBot\Prefix.txt", prefix);
  713. }
  714. }
  715. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement