(ctx context.Context, serverID string)
| 143 | } |
| 144 | |
| 145 | func (service *DiscordService) createSlashCommand(ctx context.Context, serverID string) error { |
| 146 | ctx, span, ctxLogger := service.tracer.StartWithLogger(ctx, service.logger) |
| 147 | defer span.End() |
| 148 | |
| 149 | command, _, err := service.client.Application.CreateCommand(ctx, serverID, &discord.CommandCreateRequest{ |
| 150 | Name: "httpsms", |
| 151 | Type: 1, |
| 152 | Description: "Send an SMS via httpsms.com", |
| 153 | Options: []discord.CommandCreateRequestOption{ |
| 154 | { |
| 155 | Name: "from", |
| 156 | Description: "Sender phone number", |
| 157 | Type: 3, |
| 158 | Required: true, |
| 159 | }, |
| 160 | { |
| 161 | Name: "to", |
| 162 | Description: "Recipient phone number", |
| 163 | Type: 3, |
| 164 | Required: true, |
| 165 | }, |
| 166 | { |
| 167 | Name: "message", |
| 168 | Description: "Text message content", |
| 169 | Type: 3, |
| 170 | Required: true, |
| 171 | }, |
| 172 | { |
| 173 | Name: "attachment_urls", |
| 174 | Description: "Comma-separated list of media URLs to attach", |
| 175 | Type: 3, |
| 176 | Required: false, |
| 177 | }, |
| 178 | }, |
| 179 | }) |
| 180 | if err != nil { |
| 181 | msg := fmt.Sprintf("cannot create slash command for server [%s]", serverID) |
| 182 | return service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg)) |
| 183 | } |
| 184 | |
| 185 | ctxLogger.Info(fmt.Sprintf("upserted a slash command with ID [%s] for discord server [%s] and applicationID [%s]", command.ID, serverID, command.ApplicationID)) |
| 186 | return nil |
| 187 | } |
| 188 | |
| 189 | // DiscordUpdateParams are parameters for updating an entities.Discord |
| 190 | type DiscordUpdateParams struct { |
no test coverage detected