Skip to content

Commit

Permalink
update all dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Nov 11, 2022
1 parent d64df01 commit 9e81d44
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 84 deletions.
12 changes: 6 additions & 6 deletions bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/disgoorg/disgo"
"github.com/disgoorg/disgo/bot"
"github.com/disgoorg/disgo/cache"
"github.com/disgoorg/disgo/discord"
"github.com/disgoorg/disgo/events"
"github.com/disgoorg/disgo/httpserver"
"github.com/disgoorg/disgo/oauth2"
Expand Down Expand Up @@ -39,13 +40,12 @@ func (b *RedditBot) Setup() error {
bot.WithLogger(b.Logger),
bot.WithCacheConfigOpts(
cache.WithCacheFlags(cache.FlagsNone),
cache.WithMemberCachePolicy(cache.MemberCachePolicyNone),
cache.WithMessageCachePolicy(cache.MessageCachePolicyNone),
cache.WithMemberCachePolicy(cache.PolicyNone[discord.Member]),
cache.WithMessageCachePolicy(cache.PolicyNone[discord.Message]),
),
bot.WithHTTPServerConfigOpts(
bot.WithHTTPServerConfigOpts(publicKey,
httpserver.WithAddress(webhookServerAddress),
httpserver.WithURL(InteractionCallbackURL),
httpserver.WithPublicKey(publicKey),
httpserver.WithServeMux(serveMux),
),
bot.WithEventListeners(&events.ListenerAdapter{
Expand All @@ -56,11 +56,11 @@ func (b *RedditBot) Setup() error {
}

func (b *RedditBot) Start() error {
return b.Client.StartHTTPServer()
return b.Client.OpenHTTPServer()
}

func (b *RedditBot) SetupCommands() error {
_, err := b.Client.Rest().Applications().SetGlobalCommands(b.Client.ApplicationID(), commands)
_, err := b.Client.Rest().SetGlobalCommands(b.Client.ApplicationID(), commands)
return err
}

Expand Down
13 changes: 6 additions & 7 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var subredditNamePattern = regexp.MustCompile(`\A(r/)?(?P<name>[A-Za-z\d]\w{2,20

var commands = []discord.ApplicationCommandCreate{
discord.SlashCommandCreate{
CommandName: "subreddit",
Name: "subreddit",
Description: "lets you manage all your subreddits",
Options: []discord.ApplicationCommandOption{
discord.ApplicationCommandOptionSubCommand{
Expand Down Expand Up @@ -45,11 +45,10 @@ var commands = []discord.ApplicationCommandCreate{
Description: "lists all added subreddits",
},
},
DefaultPermission: true,
},
}

func (b *RedditBot) onApplicationCommandInteraction(event *events.ApplicationCommandInteractionEvent) {
func (b *RedditBot) onApplicationCommandInteraction(event *events.ApplicationCommandInteractionCreate) {
data := event.SlashCommandInteractionData()
var err error
if data.CommandName() == "subreddit" {
Expand Down Expand Up @@ -84,7 +83,7 @@ func parseSubredditName(name string) (string, bool) {
return strings.ToLower(match[subredditNamePattern.SubexpIndex("name")]), true
}

func (b *RedditBot) onSubredditAdd(event *events.ApplicationCommandInteractionEvent, data discord.SlashCommandInteractionData) error {
func (b *RedditBot) onSubredditAdd(event *events.ApplicationCommandInteractionCreate, data discord.SlashCommandInteractionData) error {
subreddit, ok := parseSubredditName(data.String("subreddit"))
if !ok {
return event.CreateMessage(discord.NewMessageCreateBuilder().
Expand Down Expand Up @@ -113,7 +112,7 @@ func (b *RedditBot) onSubredditAdd(event *events.ApplicationCommandInteractionEv
)
}

url, state := b.OAuth2Client.GenerateAuthorizationURLState(baseURL+CreateCallbackURL, 0, *event.GuildID(), false, discord.ApplicationScopeWebhookIncoming)
url, state := b.OAuth2Client.GenerateAuthorizationURLState(baseURL+CreateCallbackURL, 0, *event.GuildID(), false, discord.OAuth2ScopeWebhookIncoming)

webhookCreateStates[state] = WebhookCreateState{
Interaction: event.ApplicationCommandInteraction,
Expand All @@ -127,7 +126,7 @@ func (b *RedditBot) onSubredditAdd(event *events.ApplicationCommandInteractionEv
)
}

func (b *RedditBot) onSubredditRemove(event *events.ApplicationCommandInteractionEvent, data discord.SlashCommandInteractionData) error {
func (b *RedditBot) onSubredditRemove(event *events.ApplicationCommandInteractionCreate, data discord.SlashCommandInteractionData) error {
subreddit, ok := parseSubredditName(data.String("subreddit"))
if !ok {
return event.CreateMessage(discord.NewMessageCreateBuilder().
Expand All @@ -154,7 +153,7 @@ func (b *RedditBot) onSubredditRemove(event *events.ApplicationCommandInteractio
)
}

func (b *RedditBot) onSubredditList(event *events.ApplicationCommandInteractionEvent) error {
func (b *RedditBot) onSubredditList(event *events.ApplicationCommandInteractionCreate) error {
var subscriptions []*Subscription
var message string
if err := b.DB.NewSelect().Model(&subscriptions).Where("guild_id = ?", *event.GuildID()).Scan(context.TODO()); err != nil {
Expand Down
12 changes: 6 additions & 6 deletions database.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"
"strconv"

"github.com/disgoorg/snowflake"
"github.com/disgoorg/snowflake/v2"
"github.com/uptrace/bun"
"github.com/uptrace/bun/dialect/pgdialect"
"github.com/uptrace/bun/driver/pgdriver"
Expand Down Expand Up @@ -42,9 +42,9 @@ func (b *RedditBot) SetupDB() error {
}

type Subscription struct {
Subreddit string `bun:"subreddit,pk"`
GuildID snowflake.Snowflake `bun:"guild_id,pk"`
ChannelID snowflake.Snowflake `bun:"channel_id,pk"`
WebhookID snowflake.Snowflake `bun:"webhook_id,notnull"`
WebhookToken string `bun:"webhook_token,notnull"`
Subreddit string `bun:"subreddit,pk"`
GuildID snowflake.ID `bun:"guild_id,pk"`
ChannelID snowflake.ID `bun:"channel_id,pk"`
WebhookID snowflake.ID `bun:"webhook_id,notnull"`
WebhookToken string `bun:"webhook_token,notnull"`
}
38 changes: 20 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,37 @@ module github.com/TopiSenpai/Reddit-Discord-Bot
go 1.18

require (
github.com/disgoorg/disgo v0.8.9
github.com/disgoorg/dislog v1.0.6-0.20220326151040-b9c67fa5c6ca
github.com/disgoorg/disgo v0.13.21
github.com/disgoorg/dislog v1.0.7
github.com/disgoorg/log v1.2.0
github.com/disgoorg/snowflake v1.1.0
github.com/sirupsen/logrus v1.8.1
github.com/uptrace/bun v1.1.1
github.com/uptrace/bun/dialect/pgdialect v1.1.1
github.com/uptrace/bun/driver/pgdriver v1.1.1
github.com/uptrace/bun/extra/bundebug v1.1.1
github.com/disgoorg/snowflake/v2 v2.0.1
github.com/sirupsen/logrus v1.9.0
github.com/uptrace/bun v1.1.8
github.com/uptrace/bun/dialect/pgdialect v1.1.8
github.com/uptrace/bun/driver/pgdriver v1.1.8
github.com/uptrace/bun/extra/bundebug v1.1.8
github.com/vartanbeno/go-reddit/v2 v2.0.1
)

require (
github.com/fatih/color v1.13.0 // indirect
github.com/golang/protobuf v1.2.0 // indirect
github.com/google/go-querystring v1.0.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/sasha-s/go-csync v0.0.0-20210812194225-61421b77c44b // indirect
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
golang.org/x/crypto v0.0.0-20220214200702-86341886e292 // indirect
golang.org/x/exp v0.0.0-20220325121720-054d8573a5d8 // indirect
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9 // indirect
google.golang.org/appengine v1.4.0 // indirect
mellium.im/sasl v0.2.1 // indirect
golang.org/x/crypto v0.2.0 // indirect
golang.org/x/exp v0.0.0-20221111094246-ab4555d3164f // indirect
golang.org/x/net v0.2.0 // indirect
golang.org/x/oauth2 v0.2.0 // indirect
golang.org/x/sys v0.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
mellium.im/sasl v0.3.0 // indirect
)
Loading

0 comments on commit 9e81d44

Please sign in to comment.