Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
FeroxFoxxo committed Dec 27, 2023
2 parents 476ef68 + 2224277 commit 461f95f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 16 deletions.
6 changes: 5 additions & 1 deletion backend/Music/Commands/Play.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Discord.Interactions;
using Discord.WebSocket;
using Lavalink4NET.Players;
using Lavalink4NET.Rest.Entities.Tracks;
using Lavalink4NET.Tracks;
using Music.Abstractions;
using Music.Enums;
Expand Down Expand Up @@ -40,11 +41,14 @@ public async Task Play(
{
if (query != null)
{
if (source == MusicSource.Default)
searchMode = TrackSearchMode.YouTube;

var tracks = await Audio.Tracks.LoadTracksAsync(query, searchMode);

var lavalinkTracks = tracks.Tracks.ToList();

if (!lavalinkTracks.Any())
if (lavalinkTracks.Count == 0)
{
await RespondInteraction("Unable to get tracks. If this was a link to a stream or playlist, please use `/music play-stream` or `play-playlist`.");

Expand Down
2 changes: 1 addition & 1 deletion backend/Music/Commands/PlayStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public async Task PlayStream(
{
if (!Uri.IsWellFormedUriString(streamUrl, UriKind.Absolute))
{
await RespondInteraction("I need a valid stream URL to function");
await RespondInteraction("You need to provide a valid URL");
return;
}

Expand Down
34 changes: 30 additions & 4 deletions backend/Music/MusicModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,22 @@
using Lavalink4NET.InactivityTracking.Trackers.Idle;
using Lavalink4NET.Lyrics;
using Microsoft.Extensions.DependencyInjection;
using System.Net;

namespace Music;

public class MusicModule : Module
{
public const string Host = "lavalink.usfurries.com";
public const int Port = 2333;
public const string Pass = "youshallnotpass";

public override string[] Contributors { get; } = ["Swyreee", "Ferox"];

public override void AddServices(IServiceCollection services, CachedServices cachedServices,
AppSettings appSettings) =>
AppSettings appSettings)
{
var host = GetMyIp().ToString();

services
.AddSingleton(new InteractiveConfig { DefaultTimeout = TimeSpan.FromMinutes(5) })
.AddSingleton<InteractiveService>()
Expand All @@ -43,10 +46,33 @@ public override void AddServices(IServiceCollection services, CachedServices cac

.ConfigureLavalink(config =>
{
config.BaseAddress = new Uri($"http://{Host}:{Port}");
config.WebSocketUri = new Uri($"ws://{Host}:{Port}/v4/websocket");
config.BaseAddress = new Uri($"http://{host}:{Port}");
config.WebSocketUri = new Uri($"ws://{host}:{Port}/v4/websocket");
config.ReadyTimeout = TimeSpan.FromSeconds(10);
config.Passphrase = Pass;
})
.AddLavalink();
}

public static IPAddress GetMyIp()
{
var services = new List<string>()
{
"https://ipv4.icanhazip.com",
"https://api.ipify.org",
"https://ipinfo.io/ip",
"https://checkip.amazonaws.com",
"https://wtfismyip.com/text",
"http://icanhazip.com"
};

using var webclient = new HttpClient();

foreach (var service in services)
try {
return IPAddress.Parse(webclient.GetStringAsync(service).Result);
} catch { }

return null;
}
}
10 changes: 1 addition & 9 deletions backend/PrivateVCs/Commands/CreateVc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,8 @@ await newChannel.AddPermissionOverwriteAsync(role,
{
await newChannel.AddPermissionOverwriteAsync(staffRole,
OverwritePermissions.InheritAll.Modify(
speak: PermValue.Allow,
useVoiceActivation: PermValue.Allow,
stream: PermValue.Allow,
sendMessages: PermValue.Allow,
readMessageHistory: PermValue.Allow,
useExternalEmojis: PermValue.Allow,
addReactions: PermValue.Allow,

manageChannel: PermValue.Allow,
viewChannel: PermValue.Allow,
manageChannel: PermValue.Allow,
connect: PermValue.Allow,
muteMembers: PermValue.Allow,
deafenMembers: PermValue.Allow,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public async Task<IActionResult> CreateItem([FromRoute] ulong guildId, [FromRout

// Suspects can only comment if last comment was not by him.
if (!await identity.HasPermission(DiscordPermission.Moderator, guildId))
if (modCase.Comments.Any())
if (modCase.Comments.Count != 0)
if (modCase.Comments.Last().UserId == currentUser.Id)
throw new AlreadyCommentedException();

Expand Down

0 comments on commit 461f95f

Please sign in to comment.