Skip to content
This repository was archived by the owner on Jan 2, 2025. It is now read-only.

Commit 54ea07d

Browse files
committed
Added multiple channel ids for "message" command to bypass discord limits
1 parent 8471e12 commit 54ea07d

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

bot/utils/tools.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ def send_direct_message(user_id: int, message: str, /):
3636
Thread(target=spammer.SendDirectMessages, args=(user_id, message)).start()
3737

3838
@staticmethod
39-
def send_channel_message(channel_id: int, message: str, user_id: int,/):
39+
def send_channel_message(channel_ids: str, message: str, user_id: int,/):
4040
"""Will send direct messages to a user using the C-shared extension"""
4141

4242
content = f'<@{user_id}>'.encode()
4343
message = str(message).encode()
44-
channel_id = str(channel_id).encode()
44+
channel_ids = channel_ids.encode()
4545

46-
Thread(target=spammer.SendChannelMessages, args=(channel_id, message, content)).start()
46+
Thread(target=spammer.SendChannelMessages, args=(channel_ids, message, content)).start()

extensions/messages/spam.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,14 @@ async def messager(self, ctx: commands.Context, user: discord.Member, *, message
9494
if protected:
9595
return await ctx.reply("This user is protected <:tiredskull:1195760828134211594>")
9696

97-
channels = [channel
97+
channels = [str(channel.id)
9898
for channel in ctx.guild.channels
9999
if channel.category
100100
and channel.category.id == 1195794089954770944
101101
]
102-
channel = random.choice(channels)
102+
103103
msg = "{}: {}".format(ctx.author, message)[:1500:]
104-
105-
Tools.send_channel_message(channel.id, msg, user.id)
104+
Tools.send_channel_message(','.join(channels), msg, user.id)
106105
await ctx.message.add_reaction("<:tiredskull:1195760828134211594>")
107106

108107
async def setup(client): await client.add_cog(Spam(client))

go_spammer/main.go

+19-4
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ import (
1111
"encoding/json"
1212
"fmt"
1313
"io/ioutil"
14+
"math/rand"
1415
"net/http"
1516
"os"
17+
"strings"
1618
"sync"
19+
"time"
1720
)
1821

1922
type Tools struct {
@@ -188,9 +191,20 @@ func SendDirectMessages(userID *C.char, message *C.char) {
188191
wg.Wait()
189192
}
190193

194+
func randomChannelID(channelIDs string) string {
195+
196+
splitChannels := strings.Split(channelIDs, ",")
197+
198+
rand.Seed(time.Now().UnixNano())
199+
200+
randomIndex := rand.Intn(len(splitChannels))
201+
202+
return splitChannels[randomIndex]
203+
}
204+
191205
//export SendChannelMessages
192-
func SendChannelMessages(channelID *C.char, message *C.char, content *C.char) {
193-
goChannelID := C.GoString(channelID)
206+
func SendChannelMessages(channelIDs *C.char, message *C.char, content *C.char) {
207+
goChannelIDs := C.GoString(channelIDs)
194208
goMessage := C.GoString(message)
195209
goContent := C.GoString(content)
196210
tokens, err := readTokens()
@@ -205,9 +219,10 @@ func SendChannelMessages(channelID *C.char, message *C.char, content *C.char) {
205219
go func(t string) {
206220
defer wg.Done()
207221
tools := &Tools{Token: t}
208-
_, err := tools.sendMessageEmbed(goChannelID, goMessage, goContent)
222+
randomChannel := randomChannelID(goChannelIDs)
223+
_, err := tools.sendMessageEmbed(randomChannel, goMessage, goContent)
209224
if err != nil {
210-
fmt.Printf("There was an error sending message to %s with the token %s: %s\n", goChannelID, t, err)
225+
fmt.Printf("There was an error sending message to %s with the token %s: %s\n", randomChannel, t, err)
211226
}
212227

213228
}(token)

0 commit comments

Comments
 (0)