Skip to content

Commit 71c921c

Browse files
authored
Add nsfw flag and marked some commands as nsfw. (botlabs-gg#1371)
* added nsfw flag * remove roast command Co-authored-by: Ashish Jhanwar <[email protected]>
1 parent c18ccc2 commit 71c921c

File tree

18 files changed

+45
-48
lines changed

18 files changed

+45
-48
lines changed

antiphishing/antiphishing.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ func checkRemoteForPhishingUrl(input []string) (*BitFlowAntiFishResponse, error)
181181
req.Header.Add("Content-Type", "application/json")
182182
req.Header.Add("Accept", "*/*")
183183
req.Header.Add("Content-Length", strconv.Itoa(len(queryString)))
184-
req.Header.Add("User-Agent", "YAGPDB")
184+
req.Header.Add("User-Agent", "YAGPDB.xyz (https://github.com/botlabs-gg/yagpdb)")
185185

186186
resp, err := client.Do(req)
187187
if err != nil {

aylien/aylien.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ func (p *Plugin) AddCommands() {
6767
Arguments: []*dcmd.ArgDef{
6868
{Name: "text", Type: dcmd.String},
6969
},
70-
SlashCommandEnabled: true,
71-
DefaultEnabled: true,
70+
SlashCommandEnabled: false,
71+
DefaultEnabled: false,
7272
RunFunc: func(cmd *dcmd.Data) (interface{}, error) {
7373
var responses []*textapi.SentimentResponse
7474
if cmd.Args[0].Value != nil {

commands/slashcommands.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ func (p *Plugin) yagCommandToSlashCommand(cmd *dcmd.RegisteredCommand) *discordg
170170
Description: common.CutStringShort(cast.Description, 100),
171171
DefaultPermission: &t,
172172
Options: opts,
173+
NSFW: cast.NSFW,
173174
}
174175
}
175176

commands/yagcommmand.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ type YAGCommand struct {
146146
slashCommandID int64
147147

148148
IsResponseEphemeral bool
149+
NSFW bool
149150
}
150151

151152
// CmdWithCategory puts the command in a category, mostly used for the help generation
@@ -175,6 +176,13 @@ func (yc *YAGCommand) Run(data *dcmd.Data) (interface{}, error) {
175176
return nil, nil
176177
}
177178

179+
if yc.NSFW {
180+
channel := data.GuildData.GS.GetChannelOrThread(data.ChannelID)
181+
if !channel.NSFW {
182+
return "This command can be used only in age-restricted channels", nil
183+
}
184+
}
185+
178186
// Send typing to indicate the bot's working
179187
if confSetTyping.GetBool() && data.TriggerType != dcmd.TriggerTypeSlashCommands {
180188
common.BotSession.ChannelTyping(data.ChannelID)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.17
44

55
require (
66
emperror.dev/errors v0.4.3
7+
golang.org/x/text v0.3.7
78
github.com/AYLIEN/aylien_textapi_go v0.6.0
89
github.com/NYTimes/gziphandler v1.1.1
910
github.com/PuerkitoBio/goquery v1.5.0
@@ -161,7 +162,6 @@ require (
161162
go.opencensus.io v0.22.5 // indirect
162163
go.uber.org/atomic v1.4.0 // indirect
163164
go.uber.org/multierr v1.1.0 // indirect
164-
golang.org/x/text v0.3.7 // indirect
165165
google.golang.org/appengine v1.6.7 // indirect
166166
google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d // indirect
167167
google.golang.org/grpc v1.34.0 // indirect

lib/discordgo/gateway.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535
)
3636

3737
var (
38-
ErrAlreadyOpen = errors.New("Connection already open")
38+
ErrAlreadyOpen = errors.New("connection already open")
3939
)
4040

4141
type GatewayIntent int
@@ -247,10 +247,10 @@ func (s *Session) Open() error {
247247
}
248248

249249
var (
250-
ErrBadAuth = errors.New("Authentication failed")
251-
ErrInvalidIntent = errors.New("One of the gateway intents passed was invalid")
252-
ErrDisabledIntent = errors.New("A intent you specified has not been enabled or not been whitelisted for")
253-
ErrInvalidShard = errors.New("You specified a invalid sharding setup")
250+
ErrBadAuth = errors.New("authentication failed")
251+
ErrInvalidIntent = errors.New("one of the gateway intents passed was invalid")
252+
ErrDisabledIntent = errors.New("an intent you specified has not been enabled or not been whitelisted for")
253+
ErrInvalidShard = errors.New("you specified a invalid sharding setup")
254254
)
255255

256256
func (g *GatewayConnectionManager) Open() error {
@@ -408,7 +408,7 @@ func (g *GatewayConnectionManager) ChannelVoiceJoin(gID, cID int64, mute, deaf b
408408
debug.PrintStack()
409409

410410
g.mu.Lock()
411-
voice, _ = g.voiceConnections[gID]
411+
voice = g.voiceConnections[gID]
412412

413413
if voice == nil {
414414
voice = &VoiceConnection{

lib/discordgo/interactions.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type ApplicationCommand struct {
4343
Description string `json:"description,omitempty"`
4444
DescriptionLocalizations *map[Locale]string `json:"description_localizations,omitempty"`
4545
Options []*ApplicationCommandOption `json:"options"`
46+
NSFW bool `json:"nsfw,omitempty"`
4647
}
4748

4849
// ApplicationCommandOptionType indicates the type of a slash command's option.

lib/discordgo/message.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ func (e *MessageEmbed) GetMarshalNil() bool {
346346
}
347347

348348
func (e *MessageEmbed) MarshalJSON() ([]byte, error) {
349-
if e.marshalnil == true {
349+
if e.marshalnil {
350350
return json.Marshal(nil)
351351
}
352352
type EmbedAlias MessageEmbed

lib/discordgo/oauth2_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,4 @@ func ExampleApplication() {
5252
// Delete the application we created.
5353
err = dg.ApplicationDelete(ap.ID)
5454
log.Printf("Delete: err: %+v\n", err)
55-
56-
return
5755
}

lib/discordgo/restapi.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,8 @@ func (s *Session) innerDoRequest(method, urlStr, contentType string, b []byte, h
220220
}
221221

222222
// we may need to send a request with extra headers
223-
if headers != nil {
224-
for k, v := range headers {
225-
req.Header.Set(k, v)
226-
}
223+
for k, v := range headers {
224+
req.Header.Set(k, v)
227225
}
228226

229227
// Not used on initial login..
@@ -656,7 +654,7 @@ func (s *Session) GuildEdit(guildID int64, g GuildParams) (st *Guild, err error)
656654
for _, r := range regions {
657655
valid = append(valid, r.ID)
658656
}
659-
err = fmt.Errorf("Region not a valid region (%q)", valid)
657+
err = fmt.Errorf("region not a valid region (%q)", valid)
660658
return
661659
}
662660
}

0 commit comments

Comments
 (0)