Skip to content

Messages

arandomnewaccount edited this page Aug 13, 2020 · 11 revisions

get messages in a channel

getRecentMessage(ChannelID,num=1,beforeDate=None)

bot.getRecentMessage("383003333751856129") #if beforeDate not given, then most recent message(s) will be returned

send text message

sendMessage(ChannelID,message,embed='',tts=False)

bot.sendMessage("383003333751856129","Hello You :)")
  • bold message: **text**
  • italicized message: *text*
  • strikethrough message: ~~text~~
  • quoted message: > text
  • code: `text`
  • spoiler: ||text||

send file

sendFile(channelID,filelocation,isurl=False,message="")

bot.sendFile("383003333751856129","https://thiscatdoesnotexist.com/",True)
  • spoiler images: rename image to SPOILER_imagename.jpg (or whatever extension it has)

send embed

sendMessage(ChannelID,message,embed='',tts=False)

embed = discum.Embedder()
embed.Title("This is a test")
embed.image('https://cdn.dribbble.com/users/189524/screenshots/2105870/04-example_800x600_v4.gif')
embed.fields('Hello!',':yum:')
embed.fields(':smile:','Testing :)')
embed.author('Tester')
bot.sendMessage("383006063751856129","",embed.read())

search messages

(if only guildID is provided, this will return most recent messages in that guild). format 25 grouped results per page, ~4 messages in each group, target messages have key "hit" in them). If you'd like to filter searchMessages to only return the messages you searched for, use filterSearchResults searchMessages(guildID,channelID=None,userID=None,mentionsUserID=None,has=None,beforeDate=None,afterDate=None,textSearch=None,afterNumResults=None)

bot.searchMessages("267624335836053506",textSearch="hello")
  • input types for the search feature:
    • channelID,userID,mentionsUserID are lists of either ints or strings
    • has is a list of strings
    • beforeDate and afterDate are ints
    • textSearch is a string
    • afterNumResults is an int (multiples of 25)

filter search results

filterSearchResults(searchResponse)

searchResponse = bot.searchMessages("267624335836053506",textSearch="hello")
bot.filterSearchResults(searchResponse)

send typing action

typingAction(channelID)

bot.typingAction("267624335836053506")

delete message

deleteMessage(channelID,messageID)

bot.deleteMessage("267624335836053506","711254483669352469")

pin message

pinMessage(channelID,messageID)

bot.pinMessage("267624335836053506","711254483669352469")

un-pin message

unPinMessage(channelID,messageID)

bot.unPinMessage("267624335836053506","711254483669352469")

get pinned messages

getPins(channelID)

bot.getPins("267624335836053506")