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 be61759 commit b8f915c
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 @@ -183,7 +183,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 @@ -200,7 +200,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 @@ -357,7 +357,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 @@ -368,7 +368,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 @@ -199,7 +199,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 @@ -209,7 +209,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 @@ -139,15 +139,15 @@ func (f *Floor) watchFloorPrice() {
}
}

err = dg.UpdateGameStatus(0, f.Activity)
err = dg.UpdateWatchStatus(0, activity)
if err != nil {
logger.Errorf("Unable to set activity: %s\n", err)
} else {
logger.Debugf("Set activity: %s", f.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 @@ -114,15 +114,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 @@ -57,7 +57,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 @@ -117,7 +117,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 @@ -286,7 +286,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 @@ -297,7 +297,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 @@ -275,7 +275,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 @@ -285,7 +285,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 @@ -633,7 +633,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 @@ -650,7 +650,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 @@ -304,7 +304,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 @@ -314,7 +314,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 @@ -215,7 +215,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 @@ -225,7 +225,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 b8f915c

Please sign in to comment.