ImplDiscordStuff #1
24
main.go
24
main.go
@ -26,7 +26,7 @@ type Config struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Discord struct {
|
type Discord struct {
|
||||||
Token string `toml:"client"`
|
Token string `toml:"token"`
|
||||||
AppID string `toml:"appid"`
|
AppID string `toml:"appid"`
|
||||||
GuildID string `toml:"guildid"`
|
GuildID string `toml:"guildid"`
|
||||||
}
|
}
|
||||||
@ -128,9 +128,9 @@ var (
|
|||||||
Type: discordgo.MessageApplicationCommand,
|
Type: discordgo.MessageApplicationCommand,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
commandsHandlers = map[string]func(s *discordgo.Session, i *discordgo.InteractionCreate){
|
commandsHandlers = map[string]func(client *discordgo.Session, i *discordgo.InteractionCreate){
|
||||||
"rickroll-em": func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
"rickroll-em": func(client *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||||
err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
err := client.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||||
Data: &discordgo.InteractionResponseData{
|
Data: &discordgo.InteractionResponseData{
|
||||||
Content: "Operation rickroll has begun",
|
Content: "Operation rickroll has begun",
|
||||||
@ -141,11 +141,11 @@ var (
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ch, err := s.UserChannelCreate(
|
ch, err := client.UserChannelCreate(
|
||||||
i.ApplicationCommandData().TargetID,
|
i.ApplicationCommandData().TargetID,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_, err = s.FollowupMessageCreate(i.Interaction, true, &discordgo.WebhookParams{
|
_, err = client.FollowupMessageCreate(i.Interaction, true, &discordgo.WebhookParams{
|
||||||
Content: fmt.Sprintf("Mission failed. Cannot send a message to this user: %q", err.Error()),
|
Content: fmt.Sprintf("Mission failed. Cannot send a message to this user: %q", err.Error()),
|
||||||
Flags: discordgo.MessageFlagsEphemeral,
|
Flags: discordgo.MessageFlagsEphemeral,
|
||||||
})
|
})
|
||||||
@ -153,7 +153,7 @@ var (
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_, err = s.ChannelMessageSend(
|
_, err = client.ChannelMessageSend(
|
||||||
ch.ID,
|
ch.ID,
|
||||||
fmt.Sprintf("%s sent you this: https://youtu.be/dQw4w9WgXcQ", i.Member.Mention()),
|
fmt.Sprintf("%s sent you this: https://youtu.be/dQw4w9WgXcQ", i.Member.Mention()),
|
||||||
)
|
)
|
||||||
@ -162,7 +162,7 @@ var (
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"google-it": func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
"google-it": func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||||
err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
err := client.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||||
Data: &discordgo.InteractionResponseData{
|
Data: &discordgo.InteractionResponseData{
|
||||||
Content: searchLink(
|
Content: searchLink(
|
||||||
@ -176,7 +176,7 @@ var (
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"stackoverflow-it": func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
"stackoverflow-it": func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||||
err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
err := client.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||||
Data: &discordgo.InteractionResponseData{
|
Data: &discordgo.InteractionResponseData{
|
||||||
Content: searchLink(
|
Content: searchLink(
|
||||||
@ -190,7 +190,7 @@ var (
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"godoc-it": func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
"godoc-it": func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||||
err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
err := client.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||||
Data: &discordgo.InteractionResponseData{
|
Data: &discordgo.InteractionResponseData{
|
||||||
Content: searchLink(
|
Content: searchLink(
|
||||||
@ -204,7 +204,7 @@ var (
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"discordjs-it": func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
"discordjs-it": func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||||
err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
err := client.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||||
Data: &discordgo.InteractionResponseData{
|
Data: &discordgo.InteractionResponseData{
|
||||||
Content: searchLink(
|
Content: searchLink(
|
||||||
@ -218,7 +218,7 @@ var (
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"discordpy-it": func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
"discordpy-it": func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||||
err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
err := client.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||||
Data: &discordgo.InteractionResponseData{
|
Data: &discordgo.InteractionResponseData{
|
||||||
Content: searchLink(
|
Content: searchLink(
|
||||||
|
Loading…
Reference in New Issue
Block a user