MCPcopy Index your code
hub / github.com/NdoleStudio/httpsms / createSlashCommand

Method createSlashCommand

api/pkg/services/discord_service.go:145–187  ·  view source on GitHub ↗
(ctx context.Context, serverID string)

Source from the content-addressed store, hash-verified

143}
144
145func (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
190type DiscordUpdateParams struct {

Callers 2

StoreMethod · 0.95
UpdateMethod · 0.95

Calls 4

CreateCommandMethod · 0.80
StartWithLoggerMethod · 0.65
WrapErrorSpanMethod · 0.65
InfoMethod · 0.65

Tested by

no test coverage detected