Skip to content

Commit

Permalink
feat: change streaming discord activity to watching
Browse files Browse the repository at this point in the history
This commit uses the new UpdateWatchStatus function of
bwmarrin/discordgo#1291 to set the activity to
watching instead of streaming.
  • Loading branch information
rickstaa committed Dec 3, 2022
1 parent d6b72fd commit 9c1fa50
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 22 deletions.
8 changes: 4 additions & 4 deletions board.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (b *Board) watchStockPrice() {
}
}

err = dg.UpdateGameStatus(0, b.Name)
err = dg.UpdateWatchStatus(0, b.Name)
if err != nil {
logger.Errorf("Unable to set activity: %s\n", err)
} else {
Expand All @@ -193,7 +193,7 @@ func (b *Board) watchStockPrice() {
activity = fmt.Sprintf("%s %s %s $%s", symbol, fmtPrice, decorator, fmtDiff)
}

err = dg.UpdateGameStatus(0, activity)
err = dg.UpdateWatchStatus(0, activity)
if err != nil {
logger.Errorf("Unable to set activity: %s\n", err)
} else {
Expand Down Expand Up @@ -348,7 +348,7 @@ func (b *Board) watchCryptoPrice() {
}
}

err = dg.UpdateGameStatus(0, b.Name)
err = dg.UpdateWatchStatus(0, b.Name)
if err != nil {
logger.Errorf("Unable to set activity: %s\n", err)
} else {
Expand All @@ -359,7 +359,7 @@ func (b *Board) watchCryptoPrice() {

// format activity
activity := fmt.Sprintf("%s $%s %s %s", strings.ToUpper(priceData.Symbol), fmtPrice, decorator, fmtDiff)
err = dg.UpdateGameStatus(0, activity)
err = dg.UpdateWatchStatus(0, activity)
if err != nil {
logger.Errorf("Unable to set activity: %s\n", err)
} else {
Expand Down
4 changes: 2 additions & 2 deletions circulating.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func (c *Circulating) watchCirculating() {
}

// set activity
err = dg.UpdateGameStatus(0, c.Activity)
err = dg.UpdateWatchStatus(0, c.Activity)
if err != nil {
logger.Errorf("Unable to set activity: %s", err)
} else {
Expand All @@ -202,7 +202,7 @@ func (c *Circulating) watchCirculating() {
} else {

// format activity
err = dg.UpdateGameStatus(0, c.Activity)
err = dg.UpdateWatchStatus(0, c.Activity)
if err != nil {
logger.Errorf("Unable to set activity: %s", err)
} else {
Expand Down
4 changes: 2 additions & 2 deletions floor.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ func (f *Floor) watchFloorPrice() {
time.Sleep(time.Duration(f.Frequency) * time.Second)
}

err = dg.UpdateGameStatus(0, activity)
err = dg.UpdateWatchStatus(0, activity)
if err != nil {
logger.Errorf("Unable to set activity: %s\n", err)
} else {
logger.Debugf("Set activity: %s", activity)
}
} else {

err = dg.UpdateGameStatus(0, price)
err = dg.UpdateWatchStatus(0, price)
if err != nil {
logger.Errorf("Unable to set activity: %s\n", err)
} else {
Expand Down
4 changes: 2 additions & 2 deletions gas.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ func (g *Gas) watchGasPrice() {
time.Sleep(time.Duration(g.Frequency) * time.Second)
}

err = dg.UpdateGameStatus(0, "Fast, Avg, Slow")
err = dg.UpdateWatchStatus(0, "Fast, Avg, Slow")
if err != nil {
logger.Errorf("Unable to set activity: %s\n", err)
} else {
logger.Debugf("Set activity")
}
} else {

err = dg.UpdateGameStatus(0, nickname)
err = dg.UpdateWatchStatus(0, nickname)
if err != nil {
logger.Errorf("Unable to set activity: %s\n", err)
} else {
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ require (
golang.org/x/text v0.3.6
modernc.org/sqlite v1.14.1
)

replace github.com/bwmarrin/discordgo => /home/ricks/Development/personal/discordgo
4 changes: 2 additions & 2 deletions holders.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (h *Holders) watchHolders() {

// set activity as desc
if h.Nickname {
err = dg.UpdateGameStatus(0, h.Activity)
err = dg.UpdateWatchStatus(0, h.Activity)
if err != nil {
logger.Errorf("Unable to set activity: %s\n", err)
} else {
Expand Down Expand Up @@ -110,7 +110,7 @@ func (h *Holders) watchHolders() {
}
} else {

err = dg.UpdateGameStatus(0, nickname)
err = dg.UpdateWatchStatus(0, nickname)
if err != nil {
logger.Errorf("Unable to set activity: %s\n", err)
} else {
Expand Down
4 changes: 2 additions & 2 deletions marketcap.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func (m *MarketCap) watchMarketCap() {
}

// set activity
err = dg.UpdateGameStatus(0, activity)
err = dg.UpdateWatchStatus(0, activity)
if err != nil {
logger.Errorf("Unable to set activity: %s", err)
} else {
Expand All @@ -290,7 +290,7 @@ func (m *MarketCap) watchMarketCap() {

// format activity
activity := fmt.Sprintf("%s %s %s%%", fmtPrice, m.Decorator, fmtDiffPercent)
err = dg.UpdateGameStatus(0, activity)
err = dg.UpdateWatchStatus(0, activity)
if err != nil {
logger.Errorf("Unable to set activity: %s", err)
} else {
Expand Down
8 changes: 4 additions & 4 deletions ticker.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func (s *Ticker) watchStockPrice() {
}
}

err = dg.UpdateGameStatus(0, activity)
err = dg.UpdateWatchStatus(0, activity)
if err != nil {
logger.Errorf("Unable to set activity: %s", err)
} else {
Expand All @@ -278,7 +278,7 @@ func (s *Ticker) watchStockPrice() {
} else {
activity := fmt.Sprintf("%s %s %s", fmtPrice, s.Decorator, fmtDiffPercent)

err = dg.UpdateGameStatus(0, activity)
err = dg.UpdateWatchStatus(0, activity)
if err != nil {
logger.Errorf("Unable to set activity: %s", err)
} else {
Expand Down Expand Up @@ -624,7 +624,7 @@ func (s *Ticker) watchCryptoPrice() {
// set activity
wg := sync.WaitGroup{}
for _, sess := range shards {
err = sess.UpdateGameStatus(0, activity)
err = sess.UpdateWatchStatus(0, activity)
if err != nil {
logger.Errorf("Unable to set activity: %s", err)
} else {
Expand All @@ -641,7 +641,7 @@ func (s *Ticker) watchCryptoPrice() {

wg := sync.WaitGroup{}
for _, sess := range shards {
err = sess.UpdateGameStatus(0, activity)
err = sess.UpdateWatchStatus(0, activity)
if err != nil {
logger.Errorf("Unable to set activity: %s", err)
} else {
Expand Down
Binary file added tickers.db
Binary file not shown.
4 changes: 2 additions & 2 deletions token.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func (t *Token) watchTokenPrice() {
}
}

err = dg.UpdateGameStatus(0, activity)
err = dg.UpdateWatchStatus(0, activity)
if err != nil {
logger.Error("Unable to set activity: ", err)
} else {
Expand All @@ -308,7 +308,7 @@ func (t *Token) watchTokenPrice() {
} else {
activity := fmt.Sprintf("%s %s $%.2f", t.Name, t.Decorator, fmtPrice)

err = dg.UpdateGameStatus(0, activity)
err = dg.UpdateWatchStatus(0, activity)
if err != nil {
logger.Error("Unable to set activity: ", err)
} else {
Expand Down
4 changes: 2 additions & 2 deletions valuelocked.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func (m *ValueLocked) watchValueLocked() {
}

// set activity
err = dg.UpdateGameStatus(0, m.Activity)
err = dg.UpdateWatchStatus(0, m.Activity)
if err != nil {
logger.Errorf("Unable to set activity: %s", err)
} else {
Expand All @@ -218,7 +218,7 @@ func (m *ValueLocked) watchValueLocked() {
} else {

// format activity
err = dg.UpdateGameStatus(0, nickname)
err = dg.UpdateWatchStatus(0, nickname)
if err != nil {
logger.Errorf("Unable to set activity: %s", err)
} else {
Expand Down

0 comments on commit 9c1fa50

Please sign in to comment.