Skip to content

Commit e544704

Browse files
committed
Check if user already in target channel
1 parent 1aa31a8 commit e544704

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/languages/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@
292292
"multipleChannelsFound": "Multiple channels found: {channels}. Please provide a more precise name.",
293293
"movedToChannel": "Moved {count} player(s) to {channel}: {players}",
294294
"userNotInVoice": "{user} is not in a voice channel.",
295+
"userAlreadyInChannel": "{user} is already in the target voice channel.",
295296
"failedToMoveUser": "Failed to move {user}.",
296297
"couldNotFindCategory": "Could not find category: {category}",
297298
"couldNotFindChannel": "Could not find channel: {channel}",

src/languages/ru.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@
292292
"multipleChannelsFound": "Найдено несколько каналов: {channels}. Пожалуйста, укажите более точное название.",
293293
"movedToChannel": "Перемещено {count} игрок(а/ов) в {channel}: {players}",
294294
"userNotInVoice": "{user} не находится в голосовом канале.",
295+
"userAlreadyInChannel": "{user} уже находится в целевом голосовом канале.",
295296
"failedToMoveUser": "Не удалось переместить {user}.",
296297
"couldNotFindCategory": "Не удалось найти категорию: {category}",
297298
"couldNotFindChannel": "Не удалось найти канал: {channel}",

src/structures/RustPlus.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1608,6 +1608,15 @@ class RustPlus extends RustPlusLib {
16081608
continue;
16091609
}
16101610

1611+
// Check if user is already in the target channel
1612+
if (member.voice.channelId === targetChannel.id) {
1613+
results.failed.push({
1614+
name: member.displayName,
1615+
reason: 'already_in_channel'
1616+
});
1617+
continue;
1618+
}
1619+
16111620
try {
16121621
await member.voice.setChannel(targetChannel);
16131622
results.moved.push(member.displayName);
@@ -1634,7 +1643,8 @@ class RustPlus extends RustPlusLib {
16341643
if (results.failed.length > 0) {
16351644
const failedMessages = results.failed.map(f =>
16361645
Client.client.intlGet(this.guildId,
1637-
f.reason === 'not_in_voice' ? 'userNotInVoice' : 'failedToMoveUser',
1646+
f.reason === 'not_in_voice' ? 'userNotInVoice' :
1647+
f.reason === 'already_in_channel' ? 'userAlreadyInChannel' : 'failedToMoveUser',
16381648
{ user: f.name }
16391649
)
16401650
);

0 commit comments

Comments
 (0)