Esempio n. 1
0
        public MessageHandler(SocketUserMessage socketMessage, List <string> commandList, BotChannelSetting channelSettings = null)
        {
            SocketMessage = socketMessage;

            // verify what to do when these 2 cant be cast
            SocketGuildUser       = socketMessage.Author as SocketGuildUser;
            SocketTextChannel     = socketMessage.Channel as SocketTextChannel;
            SocketCategoryChannel = SocketTextChannel.Category as SocketCategoryChannel;
            SocketThreadChannel   = socketMessage.Channel as SocketThreadChannel;
            SocketGuildChannel    = socketMessage.Channel as SocketGuildChannel;

            if (socketMessage.Channel is SocketThreadChannel)
            {
                // The message if from a thread -> Replace the SocketChannel to the parent channel
                if (SocketThreadChannel.ParentChannel is SocketTextChannel)
                {
                    SocketTextChannel = SocketThreadChannel.ParentChannel as SocketTextChannel;
                }

                SocketGuildChannel = SocketThreadChannel.ParentChannel;

                // TODO Fix the correct setting from the calling method
                channelSettings = CommonHelper.GetChannelSettingByThreadId(SocketThreadChannel.Id).Setting;
            }

            // Dont handle DM's
            if (SocketGuildChannel == null)
            {
                return;
            }

            SocketGuild = SocketGuildChannel.Guild;

            ChannelSettings = channelSettings;
            CommandInfos    = commandList;

            DatabaseManager = DatabaseManager.Instance();
        }
Esempio n. 2
0
 private async Task ThreadCreatedHandler(SocketThreadChannel channel)
 {
     await channel.JoinAsync();
 }