What I am trying (Discord Bot) is to make a command called !say serverID channelID arg
The point of this command is that I will pm the bot with this command and the bot writes the arg in the defined channelID from the server.
Library (litcord): https://github.com/satom99/litcord
A part of the code (Yes, this has issues...):
local server = client.servers:getAll('id', serverID)
if server then
if server.contains('id', serverID) then
for _, serverID in pairs(server) do
if serverID == serverID then
return true
end
return false
end
end
print(serverID, channelID, arg)
return end
The full code:
client:on(
'message',
function(message)
local userID = message.author.id
local cmd, serverID, channelID, arg = string.match(message.content, '(%S+) (%d+) (%d+) (%S+.*)')
local cmd = cmd or message.content
if (cmd == "!say") and message.parent.is_private then
if (userID == "187590758360940545") then
local server = client.servers:getAll('id', serverID)
if server then
if server.contains('id', serverID) then
for _, serverID in pairs(server) do
if serverID == serverID then
return true
end
return false
end
end
print(serverID, channelID, arg)
return end
local channel = server.channels:get('id', channelID)
client.channel = channelID
message.channel:sendMessage(arg)
else
message:reply(":sob: Stop!!!!")
return end
end
end
)
Things I am trying to:
Check the table to see if it has a server
and the same for channel
etc....