using NetCord; using NetCord.Services.ApplicationCommands; using StreakBot.Data.Entities; using StreakBot.Services; namespace StreakBot.Commands; public class StartCommand : ApplicationCommandModule { private readonly StreakService _streakService; public StartCommand(StreakService streakService) { _streakService = streakService; } [SlashCommand("start", "Start a daily messaging streak with another user")] public async Task Start( [SlashCommandParameter(Name = "user", Description = "The user to start a streak with")] User user) { var initiatorId = Context.User.Id; var targetId = user.Id; if (initiatorId == targetId) { return "You can't start a streak with yourself!"; } if (user.IsBot) { return "You can't start a streak with a bot!"; } Streak? success; if (Context.Interaction.GuildId is null) { // Group DM var channelId = Context.Channel.Id; success = await _streakService.CreateStreakAsync(initiatorId, targetId, 0, channelId); } else { // Server var serverId = Context.Interaction.GuildId.Value; success = await _streakService.CreateStreakAsync(initiatorId, targetId, serverId); } return success != null ? $"Streak started between <@{initiatorId}> and <@{targetId}>! Send messages daily to keep your streak alive!" : $"Streak already started between <@{initiatorId}> and <@{targetId}>!"; } }