-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_bot.lua
More file actions
33 lines (27 loc) · 1.01 KB
/
Copy pathbasic_bot.lua
File metadata and controls
33 lines (27 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
-- examples/basic_bot.lua
-- Example: Basic bot skeleton.
--
-- The smallest useful bot: connect, log when ready, reply to one prefix
-- command. Good starting point to copy for a new bot before adding
-- slash commands, buttons, or voice.
local discord = require("../init")
-- The ping command below is a prefix command, so it needs GUILD_MESSAGES
-- to see the message and MESSAGE_CONTENT (privileged, enable it on the
-- dev portal too) to read the text. default_intents() alone is not
-- enough since MESSAGE_CONTENT is privileged and excluded from it.
local intents = discord.enums.combine_intents(
discord.enums.INTENTS.GUILDS,
discord.enums.INTENTS.GUILD_MESSAGES,
discord.enums.INTENTS.MESSAGE_CONTENT
)
local bot = discord.Bot(nil, intents)
bot:on("ready", function()
print("Bot is ready!")
if bot.user then
print("Logged in as " .. bot.user.username)
end
end)
bot:command("ping", function(ctx)
ctx:reply("Pong!")
end, "Replies with pong")
bot:run(os.getenv("TOKEN") or "YOUR_BOT_TOKEN")