Exemplo n.º 1
0
        /// <summary>
        ///     Binds the module events to the bot
        /// </summary>
        /// <param name="discordClient"></param>
        public static void BindEvents(DiscordClient discordClient)
        {
            discordClient.MessageCreated += async e =>
            {
                await Task.Yield();

                DiscordEvents.TriggerChannelMessage(e);
            };
        }
Exemplo n.º 2
0
        public DiscordEventHandler(DiscordShardedClient client, IServiceProvider service,
                                   CommandService commandService)
        {
            _events = new DiscordEvents(client, service, commandService);

            client.Log             += Logger.OnLogAsync;
            client.ShardReady      += _events.ShardReadyAsync;
            client.ShardConnected  += _events.ShardConnectedAsync;
            client.MessageReceived += _events.MessageReceivedAsync;
            client.UserJoined      += _events.GuildUserJoinAsync;
            client.UserLeft        += _events.GuildUserLeaveAsync;
        }
Exemplo n.º 3
0
        public async Task GetProfileAsync([Remainder] string target)
        {
            RavenGuild guild = RavenDb.GetGuild(Context.Guild.Id);
            Regex      regex = new Regex(@"<@([0-9]*)>");
            Match      match = regex.Match(target);

            if (match.Success)
            {
                // See if what they gave was a real person
                ulong.TryParse(match.Groups[1].Value, out ulong id);
                if (id is 0)
                {
                    await ReplyAsync("Invalid User Mentioned.");

                    return;
                }

                RavenUser mentionedUser = guild.GetUser(id);
                if (mentionedUser is null)
                {
                    await ReplyAsync("The user specified doesn't exist within the system.");

                    return;
                }

                // Gotem.
                await ReplyAsync(null, false, DiscordEvents.GetUserProfile(id, guild));
            }

            else
            {
                RavenUser user = guild.Users.FirstOrDefault(x => x.Username.StartsWith(target));
                if (user is null)
                {
                    await ReplyAsync("Couldn't find anyone who's name was at all like that. To be fair, it's not a very indepth search.");

                    return;
                }

                await ReplyAsync(null, false, DiscordEvents.GetUserProfile(user.UserId, guild));
            }
        }
Exemplo n.º 4
0
 public async Task GetProfileAsync() => await ReplyAsync(null, false, DiscordEvents.GetUserProfile(Context.User.Id, null));
Exemplo n.º 5
0
 public async Task GetOwnProfileAsync() => await ReplyAsync(null, false, DiscordEvents.GetUserProfile(Context.User.Id, RavenDb.GetGuild(Context.Guild.Id)));