Skip to content

Commit

Permalink
Remove audio module
Browse files Browse the repository at this point in the history
Replaced by soundboard in Discord
  • Loading branch information
Bond-009 committed Jun 27, 2024
1 parent dade000 commit 6059291
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 217 deletions.
4 changes: 1 addition & 3 deletions src/iTool.DiscordBot/Bot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ public async Task<bool> StartAsync()
IServiceCollection serviceCollection = new ServiceCollection()
.AddSingleton(_loggerFactory)
.AddLogging()
.AddSingleton(_settings)
.AddSingleton(typeof(AudioService))
.AddSingleton(typeof(AudioFileService));
.AddSingleton(_settings);

if (string.IsNullOrEmpty(_settings.SteamKey))
{
Expand Down
19 changes: 7 additions & 12 deletions src/iTool.DiscordBot/Databases/TagDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
}

public Task<Tag> GetTagAsync(ulong guildID, string name)
=> Tags.AsQueryable()
.FirstOrDefaultAsync(x => x.GuildID == guildID && string.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase));
=> Tags.FirstOrDefaultAsync(x => x.GuildID == guildID && string.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase));

public IQueryable<Tag> GetTags(ulong guildID)
=> Tags.AsQueryable().Where(x => x.GuildID == guildID);
=> Tags.Where(x => x.GuildID == guildID);

public async Task CreateTagAsync(SocketCommandContext context, string name, string content, string attachment = null)
{
if (await Tags.AsQueryable().AnyAsync(
if (await Tags.AsNoTracking().AnyAsync(
x => x.GuildID == context.Guild.Id && string.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase)).ConfigureAwait(false))
{
throw new ArgumentException($"The tag `{name}` already exists.");
Expand All @@ -50,16 +49,12 @@ public async Task CreateTagAsync(SocketCommandContext context, string name, stri

public async Task DeleteTagAsync(SocketCommandContext context, string name)
{
Tag tag = await Tags.AsQueryable()
.FirstOrDefaultAsync(x => x.GuildID == context.Guild.Id && string.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase)).ConfigureAwait(false);

if (tag == null)
{
throw new ArgumentException($"The tag `{name}` does not exist.");
}
Tag tag = await Tags
.FirstOrDefaultAsync(x => x.GuildID == context.Guild.Id && string.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase)).ConfigureAwait(false)
?? throw new ArgumentException($"The tag `{name}` does not exist.");

var user = (SocketGuildUser)context.User;
if (tag.AuthorID != user.Id && !user.GuildPermissions.ManageMessages)
if (tag.AuthorID != user.Id && !user.GuildPermissions.ManageMessages)
{
throw new UnauthorizedAccessException($"You are not the owner of the tag `{name}`.");
}
Expand Down
8 changes: 0 additions & 8 deletions src/iTool.DiscordBot/Helpers/AudioFile.cs

This file was deleted.

44 changes: 0 additions & 44 deletions src/iTool.DiscordBot/Modules/AudioModule.cs

This file was deleted.

71 changes: 0 additions & 71 deletions src/iTool.DiscordBot/Services/AudioFileService.cs

This file was deleted.

79 changes: 0 additions & 79 deletions src/iTool.DiscordBot/Services/AudioService.cs

This file was deleted.

0 comments on commit 6059291

Please sign in to comment.