Skip to content

Commit

Permalink
updating to v4 DSharpPlus
Browse files Browse the repository at this point in the history
  • Loading branch information
PizzaConsole committed Jun 6, 2023
1 parent 0276f48 commit d8e8fb9
Show file tree
Hide file tree
Showing 9 changed files with 633 additions and 194 deletions.
15 changes: 15 additions & 0 deletions .deploy/poisncopy.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=PoisnCopy application service
[Service]
WorkingDirectory=/var/www/poisncopy
ExecStart=/usr/bin/dotnet /var/www/poisncopy/PoisnCopy.dll
Restart=always
#Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=poisncopy
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy=multi-user.target
92 changes: 46 additions & 46 deletions Commands/BasicCommandsModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,65 +3,65 @@
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using DSharpPlus.Interactivity;
using DSharpPlus.Interactivity.Extensions;
using System;
using System.Threading.Tasks;

namespace PoisnCopy.Commands
{
public class BasicCommandsModule : IModule
{
/* Commands in DSharpPlus.CommandsNext are identified by supplying a Command attribute to a method in any class you've loaded into it. */
/* The description is just a string supplied when you use the help command included in CommandsNext. */
namespace PoisnCopy.Commands;

[Command("connections")]
[Description("Simple command to see how many servers the bot is on.")]
public async Task Connections(CommandContext ctx)
{
await ctx.TriggerTypingAsync();
public class BasicCommandsModule : BaseCommandModule, IModule
{
/* Commands in DSharpPlus.CommandsNext are identified by supplying a Command attribute to a method in any class you've loaded into it. */
/* The description is just a string supplied when you use the help command included in CommandsNext. */

var connections = ctx.Client.Guilds;
await ctx.RespondAsync($"I am running on {connections} servers");
}
[Command("connections")]
[Description("Simple command to see how many servers the bot is on.")]
public async Task Connections(CommandContext ctx)
{
await ctx.TriggerTypingAsync();

[Command("alive")]
[Description("Simple command to test if the bot is running!")]
public async Task Alive(CommandContext ctx)
{
/* Trigger the Typing... in discord */
await ctx.TriggerTypingAsync();
var connections = ctx.Client.Guilds;
await ctx.RespondAsync($"I am running on {connections.ToList().Count} servers");
}

/* Send the message "I'm Alive!" to the channel the message was recieved from */
await ctx.RespondAsync("I'm alive!");
}
[Command("alive")]
[Description("Simple command to test if the bot is running!")]
public async Task Alive(CommandContext ctx)
{
/* Trigger the Typing... in discord */
await ctx.TriggerTypingAsync();

[Command("interact")]
[Description("Simple command to test interaction!")]
public async Task Interact(CommandContext ctx)
{
/* Trigger the Typing... in discord */
await ctx.TriggerTypingAsync();
/* Send the message "I'm Alive!" to the channel the message was recieved from */
await ctx.RespondAsync("I'm alive!");
}

/* Send the message "I'm Alive!" to the channel the message was recieved from */
await ctx.RespondAsync("How are you today?");
[Command("interact")]
[Description("Simple command to test interaction!")]
public async Task Interact(CommandContext ctx)
{
/* Trigger the Typing... in discord */
await ctx.TriggerTypingAsync();

var intr = ctx.Client.GetInteractivityModule(); // Grab the interactivity module
var reminderContent = await intr.WaitForMessageAsync(
c => c.Author.Id == ctx.Message.Author.Id, // Make sure the response is from the same person who sent the command
TimeSpan.FromSeconds(60) // Wait 60 seconds for a response instead of the default 30 we set earlier!
);
/* Send the message "I'm Alive!" to the channel the message was recieved from */
await ctx.RespondAsync("How are you today?");

// You can also check for a specific message by doing something like
// c => c.Content == "something"
var intr = ctx.Client.GetInteractivity(); // Grab the interactivity module
var reminderContent = await intr.WaitForMessageAsync(
c => c.Author.Id == ctx.Message.Author.Id, // Make sure the response is from the same person who sent the command
TimeSpan.FromSeconds(60) // Wait 60 seconds for a response instead of the default 30 we set earlier!
);

// Null if the user didn't respond before the timeout
if (reminderContent == null)
{
await ctx.RespondAsync("Sorry, I didn't get a response!");
return;
}
// You can also check for a specific message by doing something like
// c => c.Content == "something"

// Homework: have this change depending on if they say "good" or "bad", etc.
await ctx.RespondAsync("Sucks to suck");
// Null if the user didn't respond before the timeout
if (reminderContent.Result == null)
{
await ctx.RespondAsync("Sorry, I didn't get a response!");
return;
}

// Homework: have this change depending on if they say "good" or "bad", etc.
await ctx.RespondAsync("Sucks to suck");
}
}
Loading

0 comments on commit d8e8fb9

Please sign in to comment.