public ActionResult <CommandRead> create(CommandCreate cmd) { var model = _mapper.Map <Command>(cmd); _repo.create(model); return(Ok(model)); }
/// <summary> /// Create a new guild command. /// New guild commands will be available in the guild immediately. /// See <a href="https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command">Create Guild Application Command</a> /// </summary> /// <param name="client">Client to use</param> /// <param name="guildId">Guild ID to create the command in</param> /// <param name="create">Command to create</param> /// <param name="callback">Callback with the created command</param> /// <param name="error">Callback when an error occurs with error information</param> public void CreateGuildCommand(DiscordClient client, Snowflake guildId, CommandCreate create, Action <DiscordApplicationCommand> callback = null, Action <RestError> error = null) { if (!guildId.IsValid()) { throw new InvalidSnowflakeException(nameof(guildId)); } client.Bot.Rest.DoRequest($"/applications/{Id}/guilds/{guildId}/commands", RequestMethod.POST, create, callback, error); }
public async Task <ActionResult <CommandResponse> > CreateCommand(CommandCreate command) { var commandResponse = await this.CommandsServices.CreateCommandAsync(command); Console.WriteLine(commandResponse.Id); return(CreatedAtRoute(nameof(GetCommandById), new { Id = commandResponse.Id }, commandResponse)); }
public async Task <CommandEntity> CreateCommandAsync(CommandCreate command) { var commandEntity = Mapper.Map <CommandEntity>(command); await this.Repository.CreateCommandAsync(commandEntity); await SaveChangesAsync(); return(commandEntity); }
public ActionResult <Command> createCommand(CommandCreate cmd) { Command createCmd = _mapper.Map <Command>(cmd); _repoObj.createCommand(createCmd); var res = _repoObj.saveChanges(); // sends uri in location header to accesss the current resource return(CreatedAtRoute("getCommands", new { Id = createCmd.Id }, createCmd)); }
public ActionResult <CommandRead> CreateCommand(CommandCreate commandCreate) { var commandModel = _mapper.Map <Command>(commandCreate); _repository.CreateCommand(commandModel); _repository.SaveChanges(); var CommandReadDto = _mapper.Map <CommandRead>(commandModel); return(CreatedAtRoute(nameof(GetCommandById), new { Id = CommandReadDto.Id }, CommandReadDto)); // return Ok(CommandReadDto); }
/// <summary> /// Creates a new Application Command Builder /// </summary> /// <param name="name">Name of the command</param> /// <param name="description">Description of the command</param> /// <param name="type">Command type</param> public ApplicationCommandBuilder(string name, string description, ApplicationCommandType type) { if (string.IsNullOrEmpty(name)) { throw new ArgumentException("Value cannot be null or empty.", nameof(name)); } if (string.IsNullOrEmpty(description)) { throw new ArgumentException("Value cannot be null or empty.", nameof(description)); } _options = new List <CommandOption>(); Command = new CommandCreate { Name = name, Description = description, Type = type, Options = _options }; }
/// <summary> /// Create a new global command. /// New global commands will be available in all guilds after 1 hour. /// Note: Creating a command with the same name as an existing command for your application will overwrite the old command. /// See <a href="https://discord.com/developers/docs/interactions/application-commands#create-global-application-command">Create Global Application Command</a> /// </summary> /// <param name="client">Client to use</param> /// <param name="create">Command to create</param> /// <param name="callback">Callback with the created command</param> /// <param name="error">Callback when an error occurs with error information</param> public void CreateGlobalCommand(DiscordClient client, CommandCreate create, Action <DiscordApplicationCommand> callback = null, Action <RestError> error = null) { client.Bot.Rest.DoRequest($"/applications/{Id}/commands", RequestMethod.POST, create, callback, error); }