Okay, so recently I’ve been trying to make something as stated in the title, that kicks a user from both the game and the discord server, using via Roblox, through a command. Is this even possible and if so how? Because I honestly don’t have a single thought on this one, I thought about using webhooks to communicate to a bot but then I remembered they couldn’t ping actual users. So, if anyone has any suggestions or really any help at all would be greatly appreciated, thank you all advance!
HTTP Server thru luvit, although, I’d say this is unrecommended.
https://luvit.io
Luvit allows you to run Lua on your PC, but also, you can make a Discord bot with Lua as well (Discordia)
As for how, you’d need to set up a few things to receive input from Roblox from the game server – once again, unrecommended though
How would I even set it up though? I understand how the bot works and all that but how would this all work?
I found help in the Discord API server (and the luvit server I think). Invite codes are “discord-api” and “luvit”. Bilal was helpful to me with that. Look at the Luvit docs to try to get a good understanding of it too. They’ll help you a lot
An example of this is in GRP, they can ban users from roblox using their discord. They can also state the reason for banning the user in the discord which will be shown to the player in roblox
I see but, I don’t see how this would help, we’re basically just converting over to another language. Seems unnecessary. Any functions both Roblox and this “luvit” have in common that can share information between each other?
To kick user from the discord server, you can just make simple HTTP Post request using HTTPService to the Discord API.
You can make a Webhook and this webhook when somebody banned it sends a message and from another bot, the bot will receive that message and get the content of the message(Content must be a key for who is banned like ID or something like that)Then it search the user that has that display or nick name then it banned him
How would I do this exactly, not very fluent in making discord bots?
This method doesn’t really involve making a bot. You need to make a request using HTTPService:RequestAsync() to https://discord.com/api/v9/guilds/yourGuildId/members/userIdToKick. You need to set the method to DELETE and there must be a “authorization” header which will store your discord token (may store discord bot token instead but you would need to add “Bot” infront of it so “authorization” = “Bot bottokenhere” instead of just “authorization” = “yourtokenhere”). Right request should return a 204 status code.
I see thank you, let me try this out right now.
Alright now is this right?
local http = game:GetService("HttpService")
game.Players.PlayerAdded:Connect(function(player)
local response = http:RequestAsync(
{
Url = "https://discord.com/api/v9/guilds/yourGuildId/members/userIdToKick",
Method = "DELETE",
Headers = {
authorization = "TOKEN"
},
}
)
end)
Yeah, now just replace the yourGuildId with your discord server id and the userIdToKick with the discord user id (of the user you want to kick).
I see but, I would have to manually put it in. I was trying to make it so when I executed a command from inside a roblox game, it would kick the user from both the discord and the roblox game. Would this still work?
This would work but yeah you would need to input the discord userId manually. Although you can do something so they need to input the discord userId while entering the game (you would save it somewhere) and then the command would just use this id so you won’t need to input this manually.
Okay, that would actually work perfectly, never thought of that, thanks! Also the other stuff you mentioned would all go inside headers right?
No, this stuff should go to the url. Look at it. It contains “yourGuildId” and “userIdToKick” somewhere
I see now, thank you so much for the help, helped a lot!
Okay, so I’ve tried saving this all into a IntValue and it works fine, but I noticed when I try to print the actual value of the int value, it’s converted into +e/e
or whatever it’s called, and it doesn’t actually return the full value.
I’m unsure if this is on my side or Roblox’s side, so if you could please confirm it would help a lot!
if string.sub(message:lower(), 1, 6) == "!gkick" then
local foundplayer = string.sub(message:lower(), 8)
local plrtokick = getPlayer(foundplayer)
if plrtokick ~= nil then
plrtokick:Kick("Kicked from both Discord and Roblox")
local id = plrtokick.Stats.DiscordID
print(id.Value)
local response = http:RequestAsync(
{
Url = "https://discord.com/api/v9/guilds/850047178973511730/members/"..id.Value,
Method = "DELETE",
Headers = {
authorization = "TOKEN"
},
print("Workety worked")
}
)
end
end
ID value returns 4.6925245610747e+17
. Instead of my initial Discord ID.
Probably it’s on roblox side. Maybe it’s just print() converting this to it’s needs.