Skip to content

Commit d7d2fb9

Browse files
Yoosuf MohamedYoosuf Mohamed
authored andcommitted
v2.0.0-beta-2
1 parent cd4f3a8 commit d7d2fb9

6 files changed

Lines changed: 83 additions & 22 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ https://devforum.roblox.com/t/rblxmanager-discord-to-roblox-manager/2033252
44
> **To Do**
55
66
* Commands
7-
- [ ] Annoucemnet
7+
- [X] Annoucemnet
88
- [X] Timebased-Bans
99
* System Updates
1010
- [X] Multi Universe Support

commands/Game/ban.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
22
const BaseSlashCommand = require('../../util/BaseSlashCommand');
33
const { GAME } = require('../../config.json');
4-
const { universeSlashCommand, userIdToName } = require('../../util/Helper');
4+
const { universeSlashCommand, userIdToName, userNameToID, isNum } = require('../../util/Helper');
55

66
module.exports = class Ban extends BaseSlashCommand{
77
constructor(){
@@ -13,8 +13,18 @@ module.exports = class Ban extends BaseSlashCommand{
1313
const datastore = universe.datastore;
1414
const messager = universe.messager;
1515

16-
const userId = interaction.options.getInteger('userid');
17-
const userName = await userIdToName(userId);
16+
let userId = interaction.options.getString('user');
17+
let userName;
18+
19+
if(isNum(userId)){
20+
const data = await userNameToID(userId);
21+
22+
userId = data.id;
23+
userName = data.name;
24+
}
25+
else{
26+
userName = await userIdToName(userId);
27+
}
1828

1929
if(!userName) return await interaction.reply("Specified user doesn't exist.");
2030

@@ -72,9 +82,9 @@ module.exports = class Ban extends BaseSlashCommand{
7282
.setRequired(true)
7383
.addChoices(...currentUniverses)
7484
)
75-
.addIntegerOption((option) =>
85+
.addStringOption((option) =>
7686
option
77-
.setName('userid')
87+
.setName('user')
7888
.setDescription('User you would like to ban')
7989
.setRequired(true)
8090
)

commands/Game/isBanned.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
22
const BaseSlashCommand = require('../../util/BaseSlashCommand');
33
const { GAME } = require('../../config.json');
4-
const { universeSlashCommand, userIdToName } = require('../../util/Helper');
4+
const { universeSlashCommand, userIdToName, userNameToID, isNum } = require('../../util/Helper');
55

66

77
module.exports = class IsBanned extends BaseSlashCommand{
@@ -13,8 +13,19 @@ module.exports = class IsBanned extends BaseSlashCommand{
1313
const universe = client.universes[interaction.options.getString('universe')];
1414
const datastore = universe.datastore;
1515

16-
const userId = interaction.options.getInteger('userid');
17-
const userName = await userIdToName(userId);
16+
let userId = interaction.options.getString('user');
17+
let userName;
18+
19+
if(isNum(userId)){
20+
const data = await userNameToID(userId);
21+
22+
userId = data.id;
23+
userName = data.name;
24+
}
25+
else{
26+
userName = await userIdToName(userId);
27+
}
28+
1829
if(!userName) return await interaction.reply("Specified user doesn't exist.");
1930

2031
const banData = await datastore.GetAsync(GAME.DATASTORE_NAME, userId);
@@ -50,9 +61,9 @@ module.exports = class IsBanned extends BaseSlashCommand{
5061
.setRequired(true)
5162
.addChoices(...currentUniverses)
5263
)
53-
.addIntegerOption((option) =>
64+
.addStringOption((option) =>
5465
option
55-
.setName('userid')
66+
.setName('user')
5667
.setDescription('User you would like to check there status.')
5768
.setRequired(true)
5869
)

commands/Game/kick.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
22
const BaseSlashCommand = require('../../util/BaseSlashCommand');
33
const { GAME } = require('../../config.json');
4-
const { universeSlashCommand, userIdToName } = require('../../util/Helper');
4+
const { universeSlashCommand, userIdToName, userNameToID, isNum } = require('../../util/Helper');
55

66

77
module.exports = class Kick extends BaseSlashCommand{
@@ -13,8 +13,19 @@ module.exports = class Kick extends BaseSlashCommand{
1313
const universe = client.universes[interaction.options.getString('universe')];
1414
const messager = universe.messager;
1515

16-
const userId = interaction.options.getInteger('userid');
17-
const userName = await userIdToName(userId);
16+
let userId = interaction.options.getString('user');
17+
let userName;
18+
19+
if(isNum(userId)){
20+
const data = await userNameToID(userId);
21+
22+
userId = data.id;
23+
userName = data.name;
24+
}
25+
else{
26+
userName = await userIdToName(userId);
27+
}
28+
1829
if(!userName) return await interaction.reply("Specified user doesn't exist.");
1930

2031
const reason = interaction.options.getString('reason') ?? GAME.KICK_REASON;
@@ -56,9 +67,9 @@ module.exports = class Kick extends BaseSlashCommand{
5667
.setRequired(true)
5768
.addChoices(...currentUniverses)
5869
)
59-
.addIntegerOption((option) =>
70+
.addStringOption((option) =>
6071
option
61-
.setName('userid')
72+
.setName('user')
6273
.setDescription('User you would like to kick.')
6374
.setRequired(true)
6475
)

commands/Game/unban.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
22
const BaseSlashCommand = require('../../util/BaseSlashCommand');
33
const { GAME } = require('../../config.json');
4-
const { universeSlashCommand, userIdToName } = require('../../util/Helper');
4+
const { universeSlashCommand, userIdToName, userNameToID, isNum } = require('../../util/Helper');
55

66
module.exports = class Unban extends BaseSlashCommand{
77
constructor(){
@@ -12,10 +12,20 @@ module.exports = class Unban extends BaseSlashCommand{
1212
const universe = client.universes[interaction.options.getString('universe')];
1313
const datastore = universe.datastore;
1414

15-
const userId = interaction.options.getInteger('userid');
16-
const userName = await userIdToName(userId);
17-
if(!userName) return await interaction.reply("Specified user doesn't exist.");
15+
let userId = interaction.options.getString('user');
16+
let userName;
17+
18+
if(isNum(userId)){
19+
const data = await userNameToID(userId);
1820

21+
userId = data.id;
22+
userName = data.name;
23+
}
24+
else{
25+
userName = await userIdToName(userId);
26+
}
27+
28+
if(!userName) return await interaction.reply("Specified user doesn't exist.");
1929
const reason = interaction.options.getString('reason') ?? GAME.UNBAN_REASON;
2030

2131
const banData = {
@@ -54,9 +64,9 @@ module.exports = class Unban extends BaseSlashCommand{
5464
.setRequired(true)
5565
.addChoices(...currentUniverses)
5666
)
57-
.addIntegerOption((option) =>
67+
.addStringOption((option) =>
5868
option
59-
.setName('userid')
69+
.setName('user')
6070
.setDescription('User you would like to unban')
6171
.setRequired(true)
6272
)

util/helper.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ const userIdToName = (userId) => {
2929
return body.Username;
3030
})
3131
.catch(error => {
32+
console.log(error, "fdsfsf")
33+
return false
34+
})
35+
}
36+
37+
const userNameToID = (userName) => {
38+
return superagent("GET", `api.roblox.com/users/get-by-username?username=${userName}`)
39+
.then(response => {
40+
const { body } = response;
41+
return { id: body.Id, name: body.Username };
42+
})
43+
.catch(error => {
44+
console.log(error, "fdsfsf")
3245
return false
3346
})
3447
}
@@ -63,11 +76,17 @@ const rolesSlashCommand = () => {
6376
return roleArray;
6477
}
6578

79+
const isNum = (string) => {
80+
return /\d/.test(string);
81+
}
82+
6683
module.exports = {
6784
getFiles,
6885
roleCheck,
6986
userIdToName,
7087
universeSlashCommand,
7188
managersSlashCommand,
89+
userNameToID,
90+
isNum,
7291
rolesSlashCommand
7392
}

0 commit comments

Comments
 (0)