Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Discord.Commands;
- using Discord.WebSocket;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Reflection;
- using System.Threading.Tasks;
- using System.Web;
- namespace ZanoxDiscordBot2
- {
- public class CommandHandler
- {
- DiscordSocketClient _client;
- CommandService _service;
- public async Task InitializeAsync(DiscordSocketClient client)
- {
- _client = client;
- _service = new CommandService();
- await _service.AddModulesAsync(Assembly.GetEntryAssembly(), null);
- _client.MessageReceived += HandleCommandAsync;
- }
- private async Task HandleCommandAsync(SocketMessage s)
- {
- var msg = s as SocketUserMessage;
- bool getInvites = false;
- if (getInvites)
- {
- var invites = await (msg.Author as SocketGuildUser).Guild.GetInvitesAsync();
- string invite = invites.Select(x => x.Url).FirstOrDefault();
- }
- if (msg == null) return;
- var context = new SocketCommandContext(_client, msg);
- if (context.User.IsBot) return;
- int argPos = 0;
- if (msg.HasStringPrefix("", ref argPos) || msg.HasMentionPrefix(_client.CurrentUser, ref argPos))
- {
- Task.Run(() => _service.ExecuteAsync(context, argPos, null));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement