This is the second version of discord scraper, which use server bot to scrape channels (realtime messages and history). There is no user behaviour emulation and it doesn't act like a regular bot - you can't talk to it and it doesn't write messages itself.
To create discord bot:
- Go to your personal account settings -
Advanced
tab- turn on
Developer mode
in your Discord account - click on
Discord API
link (it is located in the exact same line in blue) - click on
DEVELOPER PORTAL
(left upper corner on newly opened page)
- turn on
- In the Developer portal, click on
Applications
. Log in again (if necessary) and then, back in theApplications
menu, click onNew Application
- Name the bot and then click
Create
. - Go to the
Bot
menu and generate a token usingAdd Bot
orReset Token
. Copy and save this token straightaway. Also in this tab:- enable
MESSAGE CONTENT INTENT
andSERVER MEMBERS INTENT
options
- enable
- Click on
OAuth2
tab (from the left-side menu) and selectbot
:- go to
Redirects
field and clickAdd Redirect
Set it to valuehttps://discord.com/api/oauth2/token
- go to
URL Generator
and pick upbot
,guilds
andmessages.read
scopes ⇒ select redirect urlhttps://discord.com/api/oauth2/token
- set the permissions:
Read messages/View Channels
andRead Message History
- follow the
Generated link
to add bot to server ⇒ select your server to add your bot to it
- go to
- Go back to Discord application and check permissions of the bot in Discord UI:
- Make sure to add bot explicitly to the channel (preferable): channel settings ⇒
Permissions
⇒Advanced permissions
⇒Roles/Members
) or to grant bot corresponding roles for access to necessary channels. - extra actions for private channels: go to server settings ⇒
Roles
tab and fixView Channels
andRead Message History
options if those are not enabled
- Make sure to add bot explicitly to the channel (preferable): channel settings ⇒
You have to be a server admin and/or you have an access to developer portal to be able to execute the steps above
Make sure to grant bot corresponding roles for access necessary channels in server settings
Additional extended guide with pictures: https://www.ionos.com/digitalguide/server/know-how/creating-discord-bot/
Discord server permissions&roles explanation: https://www.youtube.com/watch?v=LSkPwZ0x6hc
Developer portal link: https://discord.com/developers/applications
BOT_TOKEN
- the key variable to connect to the bot, could be found on Discord Developer portal, in Bot
tab
GUILD
- should be set to <server_name>
to work with only one particular server
CHANNELS
- the list of channel ids to collect messages from (str format <channel1_id,channel2_id,...,channelN_id>
); channel id could be found in channel settings menu after enabling developer mode for your account
HISTORICAL_RUN_START_DATE
- retrieve messages after this date for the very first launch*. Datetime is considered to be specified in UTC timezone. Format '%Y-%m-%dT%H:%M:%S'
is required.
*very first launch means that there is no stored messages from this server in ES (fair for every new channel form the list as well). In case if ES index is empty and HISTORICAL_RUN_START_DATE
doesn't set explicitly, the default history period is 1 day.
Every next launch will collect history starting the datetime of last message in Elasticsearch (regardless the channel).