コード例 #1
0
        public async Task SendFeedback(CommandContext ctx, [RemainingText] string message)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(message))
                {
                    await ctx.ReplyAsync("You may use this command to send a message to the bot's developer.");

                    return;
                }

                File.AppendAllText(Files.FeedbackLog, $"[{ctx.User.DebugName()}] {message}\n\n");

                foreach (var owner in ShardedClient.CurrentApplication.Owners)
                {
                    string content = $"```diff\n+Feedback received: {ctx.User.DebugName()}```\n{message}".Truncate(2000);
                    await ShardedClient.DmUserAsync(owner.Id, content);

                    await ctx.ReplyAsync($"{CustomEmoji.Check} Message sent. Thank you!");

                    return;
                }
                throw new InvalidOperationException("Couldn't find owner member");
            }
            catch (Exception e)
            {
                Log.Exception($"Sending feedback from {ctx.User.DebugName()} at {ctx.Channel.DebugName()}", e);
                await ctx.ReplyAsync("Oops, I didn't catch that, please try again. " +
                                     "If this keeps happening join the support server to let my owner know.");
            }
        }
コード例 #2
0
ファイル: OwnerModule.cs プロジェクト: superbar13/Pac-Man-Bot
        public async Task ReplyFeedback(CommandContext ctx, ulong userId, [RemainingText] string message)
        {
            try
            {
                string pre = "```diff\n+The following message was sent to you by this bot's owner." +
                             "\n-To reply to this message, use the 'feedback' command.```\n";

                await ShardedClient.DmUserAsync(userId, pre + message);

                await ctx.AutoReactAsync();
            }
            catch (Exception e)
            {
                Log.Debug($"{e.Message}");
                await ctx.AutoReactAsync(false);

                await ctx.RespondAsync($"```{e.Message}```");
            }
        }