예제 #1
0
        public async Task AddOverrideForLogChannel(ulong channelId, ulong staffRoleId)
        {
            var category  = _discordGuildService.GetChannel(channelId);
            var staffRole = _discordGuildService.GetRole(staffRoleId);

            await category.AddPermissionOverwriteAsync(staffRole,
                                                       new OverwritePermissions(addReactions : PermValue.Deny,
                                                                                viewChannel : PermValue.Allow,
                                                                                sendMessages : PermValue.Allow,
                                                                                embedLinks : PermValue.Allow,
                                                                                manageMessages : PermValue.Deny,
                                                                                attachFiles : PermValue.Allow,
                                                                                readMessageHistory : PermValue.Allow,
                                                                                useExternalEmojis : PermValue.Allow));
        }
        public async Task Handle(DirectMessageReceivedNotification notification, CancellationToken cancellationToken)
        {
            if (!_behaviourConfigurationService.HasValidConfiguration())
            {
                await notification.ReceivedMessage.Channel.SendMessageAsync(
                    "Staff on the receiving server have not set up the bot, the message could not be sent!");

                return;
            }

            var userId = notification.ReceivedMessage.Author.Id;

            var hasOpenThread = await _threadService.HasOpenThread(userId);

            ulong channelId;

            if (!hasOpenThread)
            {
                channelId = await _workflowService.CreateChannelForThread(notification.ReceivedMessage.Author);

                await _threadService.StartThread(userId, channelId);
            }
            else
            {
                channelId = await _threadService.GetOpenThreadChannelId(userId);
            }

            var channel = _discordGuildService.GetChannel(channelId);

            await channel.SendMessageAsync(notification.ReceivedMessage.Content);
        }